rabin 2 years ago
parent
commit
ea0df68f32
60 changed files with 7489 additions and 459 deletions
  1. 6 6
      module/scm_order/database - 副本/buy.php
  2. 0 0
      module/scm_order/database - 副本/buy_goods.php
  3. 0 0
      module/scm_order/database - 副本/buy_ps.php
  4. 0 0
      module/scm_order/database - 副本/buy_refund.php
  5. 0 0
      module/scm_order/database - 副本/sell.php
  6. 0 0
      module/scm_order/database - 副本/sell_goods.php
  7. 0 0
      module/scm_order/database - 副本/sell_log.php
  8. 0 0
      module/scm_order/database - 副本/sell_ps.php
  9. 0 0
      module/scm_order/database - 副本/sell_refund.php
  10. 5 83
      module/scm_order/database - 副本/servicer_in.php
  11. 179 0
      module/scm_order/database/servicer_in.php
  12. 10 0
      module/scm_order/lib/In.php
  13. 134 0
      module/scm_order/lib/Set.php
  14. 486 0
      module/scm_product/assets/pc/html/set_seller_goods.html
  15. 388 0
      module/scm_product/assets/pc/html/set_supplier_goods.html
  16. 3 3
      module/scm_product/database/info.php
  17. 20 8
      module/scm_product/lib/Info.php
  18. 139 0
      module/scm_product/lib/Set.php
  19. 1 1
      module/scm_product/lib/Sku.php
  20. 505 0
      module/scm_role/assets/pc/html/order_servicer_store.html
  21. 4 3
      module/scm_role/assets/pc/html/set_seller_goods.html
  22. 17 48
      module/scm_role/assets/pc/html/set_servicer_goods.html
  23. 341 0
      module/scm_role/assets/pc/html/set_supplier.html
  24. 15 53
      module/scm_role/assets/pc/html/set_supplier_goods.html
  25. 18 1
      module/scm_role/database/seller.php
  26. 3 3
      module/scm_role/database/seller_goods.php
  27. 242 14
      module/scm_role/database/servicer.php
  28. 130 0
      module/scm_role/database/servicer_store.php
  29. 149 0
      module/scm_role/database/servicer_store_goods.php
  30. 300 0
      module/scm_role/database/servicer_store_goods_sku.php
  31. 115 0
      module/scm_role/database/servicer_supplier.php
  32. 5 5
      module/scm_role/database/supplier.php
  33. 11 0
      module/scm_role/database/supplier_goods_sku.php
  34. 0 16
      module/scm_role/database/supplier_type.php
  35. 165 0
      module/scm_role/lib/Order.php
  36. 0 121
      module/scm_role/lib/Seller.php
  37. 47 0
      module/scm_role/lib/Servicer.php
  38. 139 0
      module/scm_role/lib/Set.php
  39. 76 90
      module/scm_role/lib/Supplier.php
  40. 157 0
      module/scm_seller/database/goods.php
  41. 317 0
      module/scm_seller/database/goods_sku.php
  42. 478 0
      module/scm_seller/database/info.php
  43. 105 0
      module/scm_seller/database/type.php
  44. 8 0
      module/scm_seller/index.php
  45. 193 0
      module/scm_servicer/database/in_order.php
  46. 173 0
      module/scm_servicer/database/in_order_goods.php
  47. 348 0
      module/scm_servicer/database/info.php
  48. 130 0
      module/scm_servicer/database/store.php
  49. 149 0
      module/scm_servicer/database/store_goods.php
  50. 300 0
      module/scm_servicer/database/store_goods_sku.php
  51. 115 0
      module/scm_servicer/database/supplier.php
  52. 8 0
      module/scm_servicer/index.php
  53. 60 0
      module/scm_servicer/lib/Manage.php
  54. 341 0
      module/scm_supplier/assets/pc/html/set_supplier.html
  55. 155 0
      module/scm_supplier/database/goods.php
  56. 317 0
      module/scm_supplier/database/goods_sku.php
  57. 359 0
      module/scm_supplier/database/info.php
  58. 3 4
      module/scm_supplier/database/type.php
  59. 8 0
      module/scm_supplier/index.php
  60. 112 0
      module/scm_supplier/lib/Set.php

+ 6 - 6
module/scm_order/database/buy.php → module/scm_order/database - 副本/buy.php

@@ -118,22 +118,22 @@ return array
             'update'    => 'text',
         ),
 
-        'ps_cash'      => array
+        'wallet_cash'      => array
         (
             'type'      => 'decimal-11,2',
-            'name'      => '配送费',
+            'name'      => '钱包抵扣金额',
             'default'   => '0',
-            'desc'      => '配送费',
+            'desc'      => '钱包抵扣金额',
             'match'     => 'option',
             'update'    => 'text',
         ),
 
-        'wallet_cash'      => array
+        'score'      => array
         (
             'type'      => 'decimal-11,2',
-            'name'      => '钱包抵扣金额',
+            'name'      => '订单总积分',
             'default'   => '0',
-            'desc'      => '钱包抵扣金额',
+            'desc'      => '订单总积分',
             'match'     => 'option',
             'update'    => 'text',
         ),

+ 0 - 0
module/scm_order/database/buy_goods.php → module/scm_order/database - 副本/buy_goods.php


+ 0 - 0
module/scm_order/database/buy_ps.php → module/scm_order/database - 副本/buy_ps.php


+ 0 - 0
module/scm_order/database/buy_refund.php → module/scm_order/database - 副本/buy_refund.php


+ 0 - 0
module/scm_order/database/sell.php → module/scm_order/database - 副本/sell.php


+ 0 - 0
module/scm_order/database/sell_goods.php → module/scm_order/database - 副本/sell_goods.php


+ 0 - 0
module/scm_order/database/sell_log.php → module/scm_order/database - 副本/sell_log.php


+ 0 - 0
module/scm_order/database/sell_ps.php → module/scm_order/database - 副本/sell_ps.php


+ 0 - 0
module/scm_order/database/sell_refund.php → module/scm_order/database - 副本/sell_refund.php


+ 5 - 83
module/scm_order/database/in.php → module/scm_order/database - 副本/servicer_in.php

@@ -7,35 +7,17 @@ $status = array
     3 => '已驳回',
 );
 
-$seller = function()
-{
-    $array = array();
-    $info = Dever::db('scm_role/sell')->select();
-    if($info)
-    {
-        $array += $info;
-    }
-    return $array;
-};
-
 return array
 (
     # 表名
-    'name' => 'in',
+    'name' => 'servicer_in',
     # 显示给用户看的名称
-    'lang' => '入库单',
+    'lang' => '入库订单',
     'order' => 98,
     'set' => array
     (
     	'status' => $status,
     ),
-    
-    'ends' => array
-    (
-        'insert' => 'shop/lib/manage.sellOrderUpdate',
-        'update' => 'shop/lib/manage.sellOrderUpdate',
-        'updatemul' => 'shop/lib/manage.setSellOrderStatusMul_commit',
-    ),
 
     # 数据结构
     'struct' => array
@@ -64,12 +46,12 @@ return array
             'list'      => 'Dever::load("scm_order/lib/sell.info#order", {id})',
         ),
 
-        'seller_id'      => array
+        'type_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '销售商',
+            'name'      => '角色ID',
             'default'   => '',
-            'desc'      => '销售商',
+            'desc'      => '角色ID',
             'match'     => 'is_numeric',
             'update'    => 'hidden',
             'search'    => array
@@ -81,22 +63,6 @@ return array
             'value'     => Dever::input('search_option_seller_id'),
         ),
 
-        'uid'       => array
-        (
-            'type'      => 'int-11',
-            'name'      => '购买人',
-            'default'   => '0',
-            'desc'      => '购买人',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-            'search'    => array
-            (
-                'api' => 'passport/user-like',
-                'col' => 'username',
-                'result' => 'id',
-            ),
-        ),
-
         'info'      => array
         (
             'type'      => 'varchar-300',
@@ -121,50 +87,6 @@ return array
             //'mul_option' => array(2 => '批量审核', 5 => '确认收货'),
         ),
 
-        'pay_date'     => array
-        (
-            'type'      => 'int-11',
-            'name'      => '付款时间',
-            'default'   => '',
-            'match'     => 'is_numeric',
-            'desc'      => '',
-            'list'      => '"{paydate}" > 0 ? date("Y-m-d H:i", {paydate}) : "-"',
-        ),
-
-        'finish_date'     => array
-        (
-            'type'      => 'int-11',
-            'name'      => '完成时间',
-            'default'   => '',
-            'match'     => 'is_numeric',
-            'desc'      => '',
-            'search'    => 'date',
-            'list'      => '"{finish_date}" ? date("Y-m-d H:i", {finish_date}) : "-"',
-        ),
-
-        'oper_date'     => array
-        (
-            'type'      => 'int-11',
-            'name'      => '审核时间',
-            'default'   => '',
-            'match'     => 'is_numeric',
-            'desc'      => '',
-            //'list'      => '"{operdate}" > 0 ? date("Y-m-d H:i:s", {operdate}) : "-"',
-            //'list_name' => '发货时间',
-            //'list_order' => 8,
-        ),
-
-        'fa_date'     => array
-        (
-            'type'      => 'int-11',
-            'name'      => '发货时间',
-            'default'   => '',
-            'match'     => 'is_numeric',
-            'desc'      => '',
-            'search'    => 'date',
-            'list'      => '"{fa_date}" > 0 ? date("Y-m-d H:i:s", {fa_date}) : "-"',
-        ),
-
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 179 - 0
module/scm_order/database/servicer_in.php

@@ -0,0 +1,179 @@
+<?php
+
+$status = array
+(
+    1 => '待审核',
+    2 => '已审核',
+    3 => '已驳回',
+);
+
+return array
+(
+    # 表名
+    'name' => 'servicer_in',
+    # 显示给用户看的名称
+    'lang' => '仓库入库单',
+    'order' => 98,
+    'set' => array
+    (
+    	'status' => $status,
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单号',
+            'default'   => '',
+            'desc'      => '订单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name'	=> '订单信息',
+            'list'      => 'Dever::load("scm_order/lib/sell.info#order", {id})',
+        ),
+
+        'type_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '角色ID',
+            'default'   => '',
+            'desc'      => '角色ID',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => array
+            (
+                'api' => 'scm_role/seller-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'value'     => Dever::input('search_option_seller_id'),
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单备注',
+            'default'   => '',
+            'desc'      => '订单备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            //'search_after' => '<br />',
+            //'mul'   => true,
+            //'mul_option' => array(2 => '批量审核', 5 => '确认收货'),
+        ),
+
+        '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'    => 'sdate',
+            'list'        => 'date("Y-m-d H:i", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        //'excel' => $excel,
+        //'mul' => $mul,
+
+        'button' => array
+        (
+            //'导出订单明细' => array('excel', 'shop/excel.sell_order'),
+        ),
+
+        'list_button' => array
+        (
+            //fast_list
+            /*
+            'list' => array('查看详情', '"sell_order_goods&project=shop&order_id={id}&page_type=&search_option_shop_type='.$search_option_shop_type.'"'),
+
+            'list11' => array('查看采购单', '"buy_order&project=shop&search_option_type=1&&search_option_parent_type=2&search_option_parent_order_id={id}&oper_table=sell_order&search_option_shop_type='.$search_option_shop_type.'"', '{status} >= 3 && {audit} == 2 && {shop_type} == 2'),
+
+            'list1' => array('审核', '"sell_order_goods&project=shop&order_id={id}&audit=1&page_type=&search_option_shop_type='.$search_option_shop_type.'"', '{status} == 2 && {shop_type} == 2'),
+
+            'oper'  => array('确认收货', '"shop/lib/manage.setSellOrderStatus?shop_id={shop_id}&order_id={id}"', '{status} == 4 && {shop_type} == 2'),
+            */
+        ),
+    ),
+
+    'request' => array
+    (
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'uid' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(5, 'list'),
+            'col' => '*',
+        ),
+
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'name' => array('yes', 'like'),
+                'shop_id' => 'yes',
+                'method' => 'yes',
+                'pay_method' => 'yes',
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 10 - 0
module/scm_order/lib/In.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace Scm_order\Lib;
+
+use Dever;
+
+class In
+{
+
+}

+ 134 - 0
module/scm_order/lib/Set.php

@@ -0,0 +1,134 @@
+<?php
+
+namespace Scm_order\Lib;
+
+use Dever;
+
+class Set
+{
+    # 获取商品列表
+    public function goods_api()
+    {
+        $id = Dever::input('id', 1);
+        $role = Dever::input('role');
+        $price_id = Dever::input('price_id', -1);
+        $source = 'scm_role/'.$role.'_goods_sku';
+        $table = '';
+        $goods_category = Dever::input('goods_category');
+        $where[$role . '_id'] = $id;
+        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList($table, $where, $goods_category, 'goods_id', array(), $price_id, $source));
+    }
+
+    # 配置商品
+    public function home_api()
+    {
+        $data = array();
+        $data['id'] = Dever::input('id', 1);
+        $data['role'] = Dever::input('role');
+        $info = Dever::db('scm_role/' . $data['role'])->find($data['id']);
+        $data['info'] = $info;
+
+        $data['host'] = Dever::url('lib/set.home', 'scm_role');
+
+        $uri = 'lib/set.goods?id=' . $data['id'] . '&role=' . $data['role'];
+
+        if (isset($info['category'])) {
+        	$uri .= '&goods_category=' . $info['category'];
+        }
+        if (isset($info['price_id'])) {
+        	$uri .= '&price_id=' . $info['price_id'];
+        }
+        $data['url'] = Dever::url($uri, 'scm_role');
+        $data['submit'] = Dever::url('lib/set.action_commit?json=1', 'scm_role');
+
+        return Dever::render('set_' . $data['role'] . '_goods', $data);
+    }
+
+    # 配置商品
+    public function action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $role = Dever::input('role');
+        $goods = Dever::json_decode($goods);
+        $id = Dever::input('id');
+
+        $col = $role . '_id';
+        $table_goods = 'scm_role/'.$role.'_goods';
+        $table_goods_sku = 'scm_role/'.$role.'_goods_sku';
+
+        $info = Dever::db('scm_role/' . $role)->one($id);
+        $where['option_' . $col] = $id;
+        $where['set_state'] = 2;
+        Dever::db($table_goods)->updates($where);
+        Dever::db($table_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;
+            }
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w[$col] = $id;
+            $w['sku_id'] = $sku_id;
+
+            if ($v['del'] == 2) {
+                $sku_info = Dever::db($table_goods_sku)->one($w);
+
+                if ($sku_info) {
+                    Dever::db($table_goods_sku)->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $t = $w;
+                $t['state'] = 1;
+                $total = Dever::db($table_goods_sku)->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db($table_goods)->one($w);
+                    if ($info) {
+                        Dever::db($table_goods)->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('scm_product/info')->one($goods_id);
+                $info = Dever::db($table_goods)->one($w);
+
+                $u = $w;
+                if (isset($v['min'])) {
+                	$u['min'] = $v['min'];
+                }
+                if (isset($v['cost_price'])) {
+                	$u['cost_price'] = $v['cost_price'];
+                }
+                
+                if (!$info) {
+                    Dever::db($table_goods)->insert($u);
+                } else {
+                    $u['where_id'] = $info['id'];
+                    $u['state'] = 1;
+                    Dever::db($table_goods)->update($u);
+                }
+
+                $u['sku_id'] = $w['sku_id'] = $sku_id;
+                $info = Dever::db($table_goods_sku)->one($w);
+
+                if (!$info) {
+                    Dever::db($table_goods_sku)->insert($u);
+                } else {
+                    $u['where_id'] = $info['id'];
+                    $u['state'] = 1;
+                    Dever::db($table_goods_sku)->update($u);
+                }
+            }
+        }
+        return 'refer';
+    }
+}

+ 486 - 0
module/scm_product/assets/pc/html/set_seller_goods.html

@@ -0,0 +1,486 @@
+<!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">
+                    <div style="display:none;">
+                        <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>
+                    <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'}">商品ID</th>
+                                <th lay-data="{field:'name'}">商品名称</th>
+                                <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
+                                <th lay-data="{field:'price', edit: 'text'}">销售价</th>
+                                <th lay-data="{field:'commission', edit: 'text'}">销售佣金</th>
+                                <th lay-data="{field:'buy_price', 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>】
+                </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 = {};
+    var commission = '<{$info["commission"]}>';
+    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 id = '<{$id}>';
+            var role = '<{$role}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {id:id, role:role, 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 = '';
+            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>'; 
+            if (node.stock == 1) {
+                addtr += '<td class="goods_total">'+node.total+'</td>';
+            } else {
+                addtr += '<td class="goods_total"> - </td>';
+            }
+
+            addtr += '<td class="goods_prices">'+node.price+'</td>';
+            var commission_price = 0;
+            var commission_string = '';
+            if (commission == 0) {
+                commission_string = '0';
+            } else {
+                if (!node.commission) {
+                    node.commission = '0';
+                }
+                commission_string = node.commission;
+                if (node.commission.indexOf('%') > -1) {
+                    node.commission = node.commission.replace('%', '');
+                    node.commission = parseFloat(node.commission);
+                    commission_price = (node.commission/100) * parseFloat(node.price);
+                } else {
+                    commission_price = parseFloat(node.commission);
+                }
+
+                if (commission) {
+                    commission_string += '+' + commission;
+                    if (commission.indexOf('%') > -1) {
+                        var commission_temp = commission.replace('%', '');
+                        commission_temp = parseFloat(commission_temp);
+                        commission_price += (commission_temp/100) * parseFloat(node.price);
+                    } else {
+                        commission_price += parseFloat(commission);
+                    }
+                    commission_price = commission_price.toFixed(2);
+                    commission_string += '=' + commission_price;
+                }
+            }
+            
+            addtr += '<td class="goods_commission"><span>'+commission_string+'</span></td>';
+
+            addtr += '<td class="goods_prices">'+node.buy_price+'</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 || node.stock != 1) {
+                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 total = 0;
+        for (var i in goods) {
+            total += goods[i].total;
+        }
+        $(".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>

+ 388 - 0
module/scm_product/assets/pc/html/set_supplier_goods.html

@@ -0,0 +1,388 @@
+<!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">
+                    <div style="display:none;">
+                        <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>
+                    <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'}">商品ID</th>
+                                <th lay-data="{field:'name'}">商品名称</th>
+                                <th lay-data="{field:'old_cost_price', edit: 'text'}">成本价</th>
+                                <th lay-data="{field:'cost_price', edit: 'text'}">出厂价</th>
+                                <th lay-data="{field:'operation'}">操作</th>
+                            </tr>
+                        </thead>
+                        <tbody id="goods">
+                            
+                        </tbody>
+                    </table>
+                </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 = {};
+    var commission = '<{$info["commission"]}>';
+    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 id = '<{$id}>';
+            var role = '<{$role}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {id:id, role:role, 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", ".cost_price", function() {
+            var num = parseFloat($(this).val());
+            var id = $(this).parent().attr('value');
+            goods[id].cost_price = num;
+            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].old_cost_price = parseFloat(goods[key].old_cost_price);
+                goods[key].cost_price = parseFloat(goods[key].cost_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 = '';
+            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">'+node.old_cost_price+'</td>';
+
+            addtr += '<td class="cost_price" value='+node.id+'><input type="tel" class="layui-input cost_price" value="'+node.cost_price+'" /></td>';
+            
+            addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></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 del(id)
+    {
+        //if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            goods[id].num = 0;
+            get(id).remove();
+            setTotal();
+        //}
+    }
+
+    function setTotal()
+    {
+        
+    }
+</script>
+</body>
+</html>

+ 3 - 3
module/scm_product/database/info.php

@@ -31,7 +31,7 @@ $type = array
 $pay_type = array
 (
 	1 => '货币支付',
-	2 => '积分支付',
+	//2 => '积分支付',
 );
 
 $commission_type = array
@@ -252,9 +252,9 @@ $config = array
 			'default' 	=> '1',
 			'desc' 		=> '支付类型',
 			'match' 	=> 'is_numeric',
-			'update'	=> 'radio',
+			//'update'	=> 'radio',
 			'option'	=> $pay_type,
-			'search'	=> 'select',
+			//'search'	=> 'select',
 			//'list'		=> true,
 			'tab'		=> 1,
 			//'control'	=> 'pay_type',

+ 20 - 8
module/scm_product/lib/Info.php

@@ -95,7 +95,7 @@ class Info
                     $other = array();
                     if ($table) {
                         $other_where[$col] = $v['id'];
-                        $other_where['sku_id'] = -1;
+                        $other_where['sku_id'] = $sku[0]['id'];
                         $other = Dever::db($table)->find($other_where);
                     }
                     
@@ -111,11 +111,9 @@ class Info
                     $result[$i]['sell_type'] = $v['sell_type'];
                     $result[$i]['buy_type'] = $v['buy_type'];
 
-                    $result[$i]['old_price'] = 0;
-                    $result[$i]['old_buy_price'] = 0;
-
-                    $result[$i]['price'] = $price ? $price : $sku[0]['price'];
-                    $result[$i]['buy_price'] = $buy_price ? $buy_price : $sku[0]['buy_price'];
+                    $result[$i]['old_price'] = $result[$i]['price'] = $price ? $price : $sku[0]['price'];
+                    $result[$i]['old_buy_price'] = $result[$i]['buy_price'] = $buy_price ? $buy_price : $sku[0]['buy_price'];
+                    $result[$i]['old_cost_price'] = $result[$i]['cost_price'] = $sku[0]['cost_price'];
                     $result[$i]['select'] = 2;
                     $result[$i]['del'] = 1;
                     $result[$i]['total'] = isset($v['total']) ? $v['total'] : 0;
@@ -134,9 +132,15 @@ class Info
                         if (isset($other['buy_price']) && $other['buy_price']) {
                             $result[$i]['buy_price'] = $other['buy_price'];
                         }
+                        if (isset($other['cost_price']) && $other['cost_price']) {
+                            $result[$i]['cost_price'] = $other['cost_price'];
+                        }
                         if (isset($other['min']) && $other['min']) {
                             $result[$i]['min'] = $other['min'];
                         }
+                        if (isset($other['source_id']) && $other['source_id']) {
+                            $result[$i]['source_id'] = $other['source_id'];
+                        }
                         if (isset($other['in_num'])) {
                             if (isset($other['out_num'])) {
                                 $result[$i]['total'] = $other['in_num'] - $other['out_num'];
@@ -192,10 +196,12 @@ class Info
                                 'commission' => $v['commission'],
                                 'sell_type' => $v['sell_type'],
                                 'buy_type' => $v['buy_type'],
-                                'old_price' => $v1['price'] ? $v1['price'] : 0,
-                                'old_buy_price' => $v1['buy_price'] ? $v1['buy_price'] : 0,
+                                'old_price' => $v1['price'],
+                                'old_buy_price' => $v1['buy_price'],
+                                'old_cost_price' => $v1['cost_price'],
                                 'price' => $price ? $price : $v1['price'],
                                 'buy_price' => $buy_price ? $buy_price : $v1['buy_price'],
+                                'cost_price' => $v1['cost_price'],
                                 'type' => $v['type'],
                                 'del' => 1,
                                 'end' => true,
@@ -225,9 +231,15 @@ class Info
                                 if (isset($other_sku['buy_price']) && $other_sku['buy_price']) {
                                     $children['buy_price'] = $other_sku['buy_price'];
                                 }
+                                if (isset($other_sku['cost_price']) && $other_sku['cost_price']) {
+                                    $children['cost_price'] = $other_sku['cost_price'];
+                                }
                                 if (isset($other_sku['min']) && $other_sku['min']) {
                                     $children['min'] = $other_sku['min'];
                                 }
+                                if (isset($other_sku['source_id']) && $other_sku['source_id']) {
+                                    $children['source_id'] = $other_sku['source_id'];
+                                }
                                 if (isset($other_sku['in_num'])) {
                                     if (isset($other_sku['out_num'])) {
                                         $children['total'] = $other_sku['in_num'] - $other_sku['out_num'];

+ 139 - 0
module/scm_product/lib/Set.php

@@ -0,0 +1,139 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Set
+{
+    # 获取商品列表
+    public function goods_api()
+    {
+        $id = Dever::input('id', 1);
+        $role = Dever::input('role');
+        $price_id = Dever::input('price_id', -1);
+        $type = Dever::input('type', 1);
+        $source = '';
+        $table = 'scm_'.$role.'/goods_sku';
+        if ($type == 2) {
+            $source = $table;
+            $table = '';
+        }
+        $goods_category = Dever::input('goods_category');
+        $where[$role . '_id'] = $id;
+        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList($table, $where, $goods_category, 'goods_id', array(), $price_id, $source));
+    }
+
+    # 配置商品
+    public function home_api()
+    {
+        $data = array();
+        $data['id'] = Dever::input('id', 1);
+        $data['role'] = Dever::input('role');
+        $info = Dever::db('scm_' . $data['role'] . '/info')->find($data['id']);
+        $data['info'] = $info;
+
+        $data['host'] = Dever::url('lib/set.home', 'scm_product');
+
+        $uri = 'lib/set.goods?id=' . $data['id'] . '&role=' . $data['role'];
+
+        if (isset($info['category'])) {
+        	$uri .= '&goods_category=' . $info['category'];
+        }
+        if (isset($info['price_id'])) {
+        	$uri .= '&price_id=' . $info['price_id'];
+        }
+        $data['url'] = Dever::url($uri, 'scm_product');
+        $data['submit'] = Dever::url('lib/set.action_commit?json=1', 'scm_product');
+
+        return Dever::render('set_' . $data['role'] . '_goods', $data);
+    }
+
+    # 配置商品
+    public function action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $role = Dever::input('role');
+        $goods = Dever::json_decode($goods);
+        $id = Dever::input('id');
+
+        $col = $role . '_id';
+        $table_goods = 'scm_'.$role.'/goods';
+        $table_goods_sku = 'scm_'.$role.'/goods_sku';
+
+        $info = Dever::db('scm_' . $role . '/info')->one($id);
+        $where['option_' . $col] = $id;
+        $where['set_state'] = 2;
+        Dever::db($table_goods)->updates($where);
+        Dever::db($table_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;
+            }
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w[$col] = $id;
+            $w['sku_id'] = $sku_id;
+
+            if ($v['del'] == 2) {
+                $sku_info = Dever::db($table_goods_sku)->one($w);
+
+                if ($sku_info) {
+                    Dever::db($table_goods_sku)->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $t = $w;
+                $t['state'] = 1;
+                $total = Dever::db($table_goods_sku)->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db($table_goods)->one($w);
+                    if ($info) {
+                        Dever::db($table_goods)->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('scm_product/info')->one($goods_id);
+                $info = Dever::db($table_goods)->one($w);
+
+                $u = $w;
+                if (isset($v['min'])) {
+                	$u['min'] = $v['min'];
+                }
+                if (isset($v['cost_price'])) {
+                	$u['cost_price'] = $v['cost_price'];
+                }
+                
+                if (!$info) {
+                    Dever::db($table_goods)->insert($u);
+                } else {
+                    $u['where_id'] = $info['id'];
+                    $u['state'] = 1;
+                    Dever::db($table_goods)->update($u);
+                }
+
+                $u['sku_id'] = $w['sku_id'] = $sku_id;
+                $info = Dever::db($table_goods_sku)->one($w);
+
+                if (!$info) {
+                    Dever::db($table_goods_sku)->insert($u);
+                } else {
+                    $u['where_id'] = $info['id'];
+                    $u['state'] = 1;
+                    Dever::db($table_goods_sku)->update($u);
+                }
+            }
+        }
+        return 'refer';
+    }
+}

+ 1 - 1
module/scm_product/lib/Sku.php

@@ -30,7 +30,7 @@ class Sku
                     $spec = Dever::db('scm_product/info_spec_value')->getGroupData(array('ids' => $key));
                     if ($spec) {
                         $copy['name'] .= '-' . $spec['name'];
-                        $copy['id'] .= '-' . $v['key'];
+                        $copy['id'] .= '-' . $v['id'];
                         if (isset($copy['value'])) {
                             $copy['value'] = $copy['id'];
                         }

+ 505 - 0
module/scm_role/assets/pc/html/order_servicer_store.html

@@ -0,0 +1,505 @@
+<!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">
+                    <div style="display:none;">
+                        <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>
+                    <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">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <th lay-data="{field:'id'}">商品ID</th>
+                                <th lay-data="{field:'name'}">商品名称</th>
+                                <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
+                                <th lay-data="{field:'name'}">供应商</th>
+                                <th lay-data="{field:'number', edit: 'text'}">入库数量</th>
+                            </tr>
+                        </thead>
+                        <tbody id="goods">
+                            
+                        </tbody>
+                    </table>
+                </div>
+                <div class="total ft16">
+                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】【<span> 入库总数量:<i class="buyNum">0</i> </span>】
+                </div>
+                <table class="reading layui-table" lay-even="">
+					<tbody>
+						<tr>
+							<td>选择<{$name}></td>
+							<td colspan="3">
+								<div class="layui-input-inline">
+									<select xm-select="store_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="store_id" id="store_id"  ></select>
+								</div>
+								<!--
+								<button class="card_reading layui-btn">读卡</button>
+								<a href="#" class="registration layui-btn layui-btn-primary">会员登记</a>
+								-->
+							</td>
+						</tr>
+						<tr>
+							<td>入库类型:</td>
+							<td>
+								<{foreach($type_config as $k => $v):}>
+								<input type="radio" class="layui-radio" name="type" id="type" title="采购入库" />
+								<{endforeach}>
+							</td>
+						</tr>
+						<tr>
+							<td>订单备注:</td>
+							<td><textarea class="layui-textarea" name="info" id="info" rows="" cols="" maxlength="200" placeholder="请输入订单备注"></textarea></td>
+						</tr>
+						<!--
+						<tr>
+							<td>会员卡号:</td>
+							<td></td>
+							<td>会员姓名:</td>
+							<td></td>
+						</tr>
+						<tr>
+							<td>会员级别:</td>
+							<td></td>
+							<td>有效期:</td>
+							<td></td>
+						</tr>
+						<tr>
+							<td>可用积分:</td>
+							<td></td>
+							<td>可用储值:</td>
+							<td></td>
+						</tr>
+						-->
+					</tbody>
+				</table>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认入库">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    var source = <{$source}>;
+    var goods = {};
+    var del_goods = {};
+    var tree = {};
+    var commission = '<{$info["commission"]}>';
+    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 id = '<{$id}>';
+            var role = '<{$role}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {id:id, role:role, 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();
+        });
+    })
+
+    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 = goods[key].min;
+                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 = '';
+            select = '<select name="source[]" class="source" style="width: 120px;margin: 10px;" onchange="setSource($(this), \''+node.id+'\')" lay-ignore>';
+            var i = 0;
+            
+            var selected = '';
+            for (var i in source) {
+                if (source[i].id) {
+                    var id = source[i].id;
+                    selected = '';
+                    if (node.source_id && node.source_id == id) {
+                        selected = 'selected';
+                    }
+                    select += '<option value="'+id+'" '+selected+'>'+source[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>'; 
+            if (node.stock == 1) {
+                addtr += '<td class="goods_total">'+node.total+'</td>';
+            } else {
+                addtr += '<td class="goods_total"> - </td>';
+            }
+
+            addtr += '<td class="goods_source">'+select+'</td>';    
+
+            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 += '</tr>';
+            $("#goods").append(addtr);
+            form.render();
+            $('.source').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 setSource(e, id)
+    {
+        goods[id].source_id = e.val();
+    }
+    
+    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 total = 0;
+        var buy = 0;
+        for (var i in goods) {
+            total += goods[i].total;
+            buy += goods[i].num;
+        }
+        $(".totalNum").html(total);
+        $(".buyNum").html(buy);
+    }
+
+    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>

+ 4 - 3
module/scm_role/assets/pc/html/set_seller_goods.html

@@ -57,7 +57,7 @@
                     <table class="layui-table">
                         <thead>
                             <tr>
-                                <th lay-data="{field:'id'}">商品编码</th>
+                                <th lay-data="{field:'id'}">商品ID</th>
                                 <th lay-data="{field:'name'}">商品名称</th>
                                 <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
                                 <th lay-data="{field:'price', edit: 'text'}">销售价</th>
@@ -125,13 +125,14 @@
     {
         $("#settlement").click(function(){
             var url = '<{$submit}>';
-            var seller_id = '<{$seller_id}>';
+            var id = '<{$id}>';
+            var role = '<{$role}>';
 
             layui.layer.confirm('确定进行此项设置吗?', function() {
                 var goods_string = JSON.stringify(goods);
 
                 var data = {};
-                data = {seller_id:seller_id, goods:goods_string};
+                data = {id:id, role:role, goods:goods_string};
                 $.post(url, data, function(t) {
                     t = JSON.parse(t);
                     if (t.status == 1) {

+ 17 - 48
module/scm_role/assets/pc/html/buy_seller_goods.html → module/scm_role/assets/pc/html/set_servicer_goods.html

@@ -57,12 +57,10 @@
                     <table class="layui-table">
                         <thead>
                             <tr>
-                                <th lay-data="{field:'id'}">商品编码</th>
+                                <th lay-data="{field:'id'}">商品ID</th>
                                 <th lay-data="{field:'name'}">商品名称</th>
                                 <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
-                                <th lay-data="{field:'buy_price', edit: 'text'}">采购价</th>
-                                <th lay-data="{field:'buy_min', edit: 'text'}">采购起订数</th>
-                                <th lay-data="{field:'number', edit: 'text'}">采购数量</th>
+                                <th lay-data="{field:'operation'}">操作</th>
                             </tr>
                         </thead>
                         <tbody id="goods">
@@ -71,10 +69,10 @@
                     </table>
                 </div>
                 <div class="total ft16">
-                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】【<span> 采购总数量:<i class="buyNum">0</i> </span>】
+                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】
                 </div>
                 <div class="towbtn">
-                    <input type="button" id="settlement" value="确认购买">
+                    <input type="button" id="settlement" value="确认设置">
                 </div>
             </div>
         </div>
@@ -123,13 +121,14 @@
     {
         $("#settlement").click(function(){
             var url = '<{$submit}>';
-            var seller_id = '<{$seller_id}>';
+            var id = '<{$id}>';
+            var role = '<{$role}>';
 
             layui.layer.confirm('确定进行此项设置吗?', function() {
                 var goods_string = JSON.stringify(goods);
 
                 var data = {};
-                data = {seller_id:seller_id, goods:goods_string};
+                data = {id:id, role:role, goods:goods_string};
                 $.post(url, data, function(t) {
                     t = JSON.parse(t);
                     if (t.status == 1) {
@@ -312,7 +311,7 @@
                 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 = goods[key].min;
+                goods[key].num = 0;
                 goods[key].del = 1;
                 create(node);
                 setTotal();
@@ -334,22 +333,22 @@
             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>'; 
+
             if (node.stock == 1) {
                 addtr += '<td class="goods_total">'+node.total+'</td>';
             } else {
                 addtr += '<td class="goods_total"> - </td>';
             }
 
-            addtr += '<td class="goods_prices">'+node.buy_price+'</td>';
-
-            addtr += '<td class="goods_prices">'+node.min+'</td>';
-
-            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.min+'" class="goods_num"><span class="jia" onclick="add(\''+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();
         }
     }
 
@@ -380,24 +379,6 @@
         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('确定删除吗?')) {
@@ -412,25 +393,13 @@
     {
         var cash = 0;
         var total = 0;
-        var buy = 0;
+        var num = 0;
         for (var i in goods) {
             total += goods[i].total;
-            buy += goods[i].num;
+            num += goods[i].num;
         }
         $(".totalNum").html(total);
-        $(".buyNum").html(buy);
-    }
-
-    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;
-        });
+        $(".addNum").html(num);
     }
 </script>
 </body>

+ 341 - 0
module/scm_role/assets/pc/html/set_supplier.html

@@ -0,0 +1,341 @@
+<!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>选择<{$name}>:</label>
+                    <div class="layui-input-inline">
+
+                        <div><select xm-select="sid" 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="sid" id="sid"  ></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>
+                <div class="goods_list" style="height:645px;">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <th lay-data="{field:'id'}">供应商ID</th>
+                                <th lay-data="{field:'id'}">供应商编码</th>
+                                <th lay-data="{field:'name'}">供应商名称</th>
+                                <th lay-data="{field:'name'}">供应商类型</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>】
+                </div>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认分配">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    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;
+    });
+
+    $(function()
+    {
+        $("#settlement").click(function(){
+            var url = '<{$submit}>';
+            var id = '<{$id}>';
+            var role = '<{$role}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {id:id, role:role, value: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);
+                    }
+                });
+            });
+        })
+    })
+    var goods = {};
+    var del_goods = {};
+    mini.parse();
+    var 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 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 setGoods(node)
+    {
+        if (node.id) {
+            var key = node.id;
+            if (!goods[key]) {
+                goods[key] = node;
+                create(node);
+                setTotal();
+            } else {
+                add(key);
+            }
+        }
+    }
+
+    function unsetGoods(node)
+    {
+        if (node.id) {
+            if (goods[node.id]) {
+                delete goods[node.id];
+                get(node.id).remove();
+            }
+        }
+    }
+
+    function get(key)
+    {
+        return $('#goods_' + key);
+    }
+
+    function create(node)
+    {
+        if (!get(node.id).length) {
+            var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
+            addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_id">'+node.code+'</td>';
+            addtr += '<td class="goods_name">'+node.name+'</td>';     
+            addtr += '<td class="goods_name">'+node.type_name+'</td>';     
+            addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';        
+            addtr += '</tr>';
+            $("#goods").append(addtr);
+        }
+    }
+
+    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 del(id)
+    {
+        if (confirm('确定删除吗?')) {
+            delete goods[id];
+			get(id).remove();
+			setTotal();
+        }
+    }
+
+    // 一键添加
+    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 setTotal()
+    {
+        var num = 0;
+        for (var i in goods) {
+            num += 1;
+        }
+        $(".totalNum").html(num);
+    }
+
+    function setShop()
+    {
+        var sid = $('.xm-select-parent[fs_id="sid"] span[fsw="xm-select"]').attr('value');
+        if (!sid) {
+            layui.layer.alert('请选择<{$name}>');
+            return;
+        }
+        layui.layer.confirm('确定切换<{$name}>吗?', function() {
+            location.href = '<{$host}>&id=' + sid;
+        });
+    }
+</script>
+</body>
+</html>

+ 15 - 53
module/scm_role/assets/pc/html/set_supplier_goods.html

@@ -57,11 +57,10 @@
                     <table class="layui-table">
                         <thead>
                             <tr>
-                                <!--<th lay-data="{field:'id'}">商品编码</th>-->
+                                <th lay-data="{field:'id'}">商品ID</th>
                                 <th lay-data="{field:'name'}">商品名称</th>
-                                <th lay-data="{field:'buy_price', edit: 'text'}">采购价</th>
-                                <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
-                                <th lay-data="{field:'number', edit: 'text'}">新增库存</th>
+                                <th lay-data="{field:'old_cost_price', edit: 'text'}">成本价</th>
+                                <th lay-data="{field:'cost_price', edit: 'text'}">出厂价</th>
                                 <th lay-data="{field:'operation'}">操作</th>
                             </tr>
                         </thead>
@@ -70,9 +69,6 @@
                         </tbody>
                     </table>
                 </div>
-                <div class="total ft16">
-                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】【<span> 当前新增库存:<i class="addNum">0</i> </span>】
-                </div>
                 <div class="towbtn">
                     <input type="button" id="settlement" value="确认设置">
                 </div>
@@ -123,13 +119,14 @@
     {
         $("#settlement").click(function(){
             var url = '<{$submit}>';
-            var supplier_id = '<{$supplier_id}>';
+            var id = '<{$id}>';
+            var role = '<{$role}>';
 
             layui.layer.confirm('确定进行此项设置吗?', function() {
                 var goods_string = JSON.stringify(goods);
 
                 var data = {};
-                data = {supplier_id:supplier_id, goods:goods_string};
+                data = {id:id, role:role, goods:goods_string};
                 $.post(url, data, function(t) {
                     t = JSON.parse(t);
                     if (t.status == 1) {
@@ -148,16 +145,12 @@
             });
         })
 
-        $("#goods").on("keyup", ".goods_num", function() {
+        $("#goods").on("keyup", ".cost_price", function() {
             var num = parseFloat($(this).val());
-            if (num < 0) {
-                num = 0;
-                $(this).val(0);
-            }
             var id = $(this).parent().attr('value');
-            goods[id].num = num;
+            goods[id].cost_price = num;
             setTotal();
-        });
+        })
     })
 
     function search() 
@@ -308,7 +301,8 @@
             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].old_cost_price = parseFloat(goods[key].old_cost_price);
+                goods[key].cost_price = parseFloat(goods[key].cost_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;
@@ -332,26 +326,14 @@
         if (!get(node.id).length) {
             var select = '';
             var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
-            //addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_id">'+node.id+'</td>';
             addtr += '<td class="goods_name">'+node.name+'</td>'; 
 
-            addtr += '<td class="goods_prices">'+node.buy_price+'</td>';
+            addtr += '<td class="goods_prices">'+node.old_cost_price+'</td>';
 
-            if (node.stock == 1) {
-                addtr += '<td class="goods_total">'+node.total+'</td>';
-                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>';
-            } else {
-                addtr += '<td class="goods_total"> - </td>';
-                addtr += '<td class="goods_total"> - </td>';
-            }
+            addtr += '<td class="cost_price" value='+node.id+'><input type="tel" class="layui-input cost_price" value="'+node.cost_price+'" /></td>';
             
             addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
-            /*
-            if (node.total <= 0 || node.stock != 1) {
-                addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
-            } else {
-                addtr += '<td></td>';
-            }*/
                                   
             addtr += '</tr>';
             $("#goods").append(addtr);
@@ -399,27 +381,7 @@
 
     function setTotal()
     {
-        var cash = 0;
-        var total = 0;
-        var num = 0;
-        for (var i in goods) {
-            total += goods[i].total;
-            num += goods[i].num;
-        }
-        $(".totalNum").html(total);
-        $(".addNum").html(num);
-    }
-
-    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>

+ 18 - 1
module/scm_role/database/seller.php

@@ -60,6 +60,11 @@ $identity = array
 	3 => '企业',
 );
 
+$stock = array
+(
+    1 => '独立库存',
+    2 => '共享库存',
+);
 $stock = array
 (
 	1 => '独立库存',
@@ -112,6 +117,18 @@ return array
 			'edit'		=> true,
 		),
 
+        'code'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '销售商编码',
+            'default'   => '',
+            'desc'      => '销售商编码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
 		'info'      => array
         (
             'type'      => 'varchar-800',
@@ -426,7 +443,7 @@ return array
         ),
         'list_button' => array
         (
-        	'location' => array('商品设置', Dever::url('lib/seller.setGoods', 'scm_role'), '{stock} == 1'),
+        	'location' => array('商品设置', Dever::url('lib/set.home?role=seller', 'scm_role'), '{stock} == 1'),
             'br3' => array('<br />'),
             'location1' => array('订货下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
             'location2' => array('入库下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),

+ 3 - 3
module/scm_role/database/seller_goods.php

@@ -74,9 +74,9 @@ return array
             'match'     => array('is_numeric', time()),
             'desc'      => '',
             # 只有insert时才生效
-            //'insert'    => true,
-            //'search'    => 'date',
-            //'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
         ),
     ),
 

+ 242 - 14
module/scm_role/database/servicer.php

@@ -1,9 +1,8 @@
 <?php
-
-$type = function()
+$category = function()
 {
 	$array = array();
-	$data = Dever::load('scm_role/servicer_type-state');
+	$data = Dever::load('scm_product/category-getTop');
 	if($data)
 	{
 		$array += $data;
@@ -11,6 +10,19 @@ $type = function()
 	return $array;
 };
 
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+$status = array
+(
+    1 => '启用',
+    2 => '禁用',
+);
+
 return array
 (
 	# 表名
@@ -30,8 +42,8 @@ return array
 			'default' 	=> '',
 			'desc' 		=> '',
 			'match' 	=> 'is_numeric',
-			'list'		=> true,
-			'order'		=> 'asc',
+			//'list'		=> true,
+			//'order'		=> 'desc',
 		),
 
 		'name'		=> array
@@ -47,15 +59,213 @@ return array
 			'edit'		=> true,
 		),
 
-		'type_id'        => array
+		'code'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '配送商编码',
+            'default'   => '',
+            'desc'      => '配送商编码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'category'      => array
+        (
+            'type'      => 'varchar-2000',
+            'name'      => '商品属性分类-如不选择就是可以选择所有商品属性分类下的商品',
+            'default'   => '',
+            'desc'      => '商品属性分类',
+            'match'     => 'is_string',
+            'update'    => 'checkbox',
+            'option'    => $category,
+        ),
+
+		'scm_role-servicer_store'=> array
+		(
+			'name' 		=> '仓库设置',
+			'default' 	=> '',
+			'desc' 		=> '仓库设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'servicer_id'),
+			'update'	=> array(1),
+			# 1纵向展示 2横向展示
+			'update_type' => 2,
+			'list'		=> 'Dever::load("scm_role/lib/servicer.getStore", {id})',
+		),
+
+		'truename'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '联系人姓名',
+            'default'   => '',
+            'desc'      => '请输入联系人姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'tel'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人电话',
+            'default'   => '',
+            'desc'      => '请输入联系人电话',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'email'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人邮箱',
+            'default'   => '',
+            'desc'      => '联系人邮箱',
+            'match'     => 'option',
+            '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'      => '配送商类型',
+            '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'      => '配送商类型',
+            'desc'      => '供应商身份',
             'match'     => 'is_numeric',
             'update'    => 'radio',
-            'option'    => $type,
+            '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
@@ -72,6 +282,20 @@ return array
 			'order'		=> 'desc',
 			'edit'		=> true,
 		),
+
+		'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            'edit'      => true,
+        ),
 		
 		'state'		=> array
 		(
@@ -97,19 +321,23 @@ return array
 
 	'manage' => array
 	(
+		'tab' => array('基本设置', '联系人信息', '认证信息'),
 		'delete' => false,
-		'button' => array
+		'list_button' => array
         (
-            '类型配置' => array('list', 'servicer_type&oper_parent=servicer'),
-        ),
+        	'location' => array('供应商', Dever::url('lib/supplier.set?role=servicer', 'scm_role')),
+            'br3' => array('<br />'),
+            'list1' => array('入库单', 'servicer_in&project=scm_order&oper_table=servicer&oper_project=scm_role&search_option_servicer_id={id}'),
+            'list2' => array('出库单', 'servicer_out&project=scm_order&oper_table=servicer&oper_project=scm_role&search_option_servicer_id={id}'),
+        )
 	),
 
 	'default' => array
 	(
-		'col' => 'name,type_id,state,cdate',
+		'col' => 'name,code,state,cdate',
 		'value' => array
 		(
-			'"默认配送商", 1, 1,' . DEVER_TIME,
+			'"默认配送商", "default", 1, 1,' . DEVER_TIME,
 		),
 	),
 

+ 130 - 0
module/scm_role/database/servicer_store.php

@@ -0,0 +1,130 @@
+<?php
+
+$status = array
+(
+	1 => '启用',
+	2 => '禁用',
+);
+return array
+(
+	# 表名
+	'name' => 'servicer_store',
+	# 显示给用户看的名称
+	'lang' => '配送商仓库',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	'status' => $status,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'servicer_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '配送商ID',
+			'default' 	=> '-1',
+			'desc' 		=> '配送商ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_servicer_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '仓库名称',
+			'default' 	=> '',
+			'desc' 		=> '仓库名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'code'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '仓库编码',
+            'default'   => '',
+            'desc'      => '仓库编码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否启用',
+			'default' 	=> '1',
+			'desc' 		=> '是否启用',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $status,
+			'list'		=> true,
+			'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
+	(
+		'delete' => false,
+        
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 149 - 0
module/scm_role/database/servicer_store_goods.php

@@ -0,0 +1,149 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'servicer_store_goods',
+    # 显示给用户看的名称
+    'lang' => '仓库商品列表',
+    'order' => 10,
+    'menu'  => false,
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'servicer_store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属配送商',
+            'default'   => '',
+            'desc'      => '所属配送商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_servicer_store_id'),
+            'list'      => 'Dever::load("scm_role/servicer_store-one#name", {servicer_store_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_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' => 'scm_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' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,cdate',
+        ),
+
+        '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' => 'scm_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' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,t_1.cdate,t_1.id as id',
+        ),
+    ),
+);

+ 300 - 0
module/scm_role/database/servicer_store_goods_sku.php

@@ -0,0 +1,300 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'servicer_store_goods_sku',
+    # 显示给用户看的名称
+    'lang' => '商品价格设置',
+    'order' => 200,
+    'menu' => false,
+
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'servicer_store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属配送商',
+            'default'   => '',
+            'desc'      => '所属配送商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_servicer_store_id'),
+            'list'      => 'Dever::load("scm_role/servicer_store-one#name", {servicer_store_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' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'in_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库库存',
+            'default'   => '0',
+            'desc'      => '入库库存',
+            'match'     => 'is_numeric',
+        ),
+
+        'out_num'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '出库库存',
+            'default'   => '0',
+            'desc'      => '出库库存',
+            'match'     => 'option',
+        ),
+
+        '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.in_num-t_1.out_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' => 'scm_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(30, 'list'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_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.in_num-t_1.out_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' => 'scm_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.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num,t_1.in_num,t_2.type,t_2.stock,t_2.commission,t_2.sell_type,t_2.buy_type',
+        ),
+
+       	# 列表
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*,in_num-out_num as total|sku_id',
+        ),
+
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*,in_num-out_num as total',
+        ),
+
+        # 更新售出量
+        'incSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少售出量
+        'decSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '-='),
+            ),
+        ),
+
+        # 更新总库存
+        'updateTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 增加总库存
+        'incTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少总库存
+        'decTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '-='),
+            ),
+        ),
+    ),
+);
+
+return $config;

+ 115 - 0
module/scm_role/database/servicer_supplier.php

@@ -0,0 +1,115 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'servicer_supplier',
+    # 显示给用户看的名称
+    'lang' => '配送商供应商关系表',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'servicer_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '配送商ID',
+			'default' 	=> '-1',
+			'desc' 		=> '配送商ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_servicer_id'),
+		),
+
+        'supplier_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '供应商ID',
+            'default'   => '',
+            'desc'      => '供应商ID',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_supplier_id'),
+            'list'      => 'Dever::load("scm_role/supplier-one#name", {supplier_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
+    (
+        
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            'option' => array
+            (
+                'servicer_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*|supplier_id',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'servicer_id' => array('yes-t_1.servicer_id'),
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_role/supplier',
+                    'type' => 'left join',
+                    'on' => array('supplier_id','id'),
+                    'col' => 'supplier_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'col' => '*,t_2.name',
+        ),
+    ),
+);

+ 5 - 5
module/scm_role/database/supplier.php

@@ -75,7 +75,7 @@ return array
         (
             'type'      => 'varchar-150',
             'name'      => '供应商编码',
-            'default'   => '-1',
+            'default'   => '',
             'desc'      => '供应商编码',
             'match'     => 'is_string',
             'update'    => 'text',
@@ -92,6 +92,7 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $type,
+            'list'      => true,
         ),
 
         'category'		=> array
@@ -203,9 +204,9 @@ return array
         'identity'        => array
         (
             'type'      => 'tinyint-1',
-            'name'      => '销售商身份',
+            'name'      => '供应商身份',
             'default'   => '1',
-            'desc'      => '销售商身份',
+            'desc'      => '供应商身份',
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $identity,
@@ -338,8 +339,7 @@ return array
         ),
         'list_button' => array
         (
-        	'location' => array('商品列表', Dever::url('lib/supplier.setGoods', 'scm_role')),
-            //'fast_add' => array('账户操作', 'push&project=account&oper_table=supplier&oper_project=scm_role&uid={id}'),
+        	'location' => array('商品设置', Dever::url('lib/set.home?role=supplier', 'scm_role')),
         )
 	),
 

+ 11 - 0
module/scm_role/database/supplier_goods_sku.php

@@ -75,6 +75,17 @@ $config = array
             'match'     => 'is_numeric',
         ),
 
+        'cost_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '成本价',
+            'default'   => '',
+            'desc'      => '成本价',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
         'in_num'        => array
         (
             'type'      => 'decimal-11,2',

+ 0 - 16
module/scm_role/database/supplier_type.php

@@ -1,10 +1,5 @@
 <?php
 
-$stock = array
-(
-	1 => '是',
-	2 => '否',
-);
 return array
 (
 	# 表名
@@ -42,17 +37,6 @@ return array
 			'edit'		=> true,
 		),
 
-		'stock'        => array
-        (
-            'type'      => 'tinyint-1',
-            'name'      => '是否有库存',
-            'default'   => '1',
-            'desc'      => '是否有库存',
-            'match'     => 'is_numeric',
-            'update'    => 'radio',
-            'option'    => $stock,
-        ),
-
 		'reorder'		=> array
 		(
 			'type' 		=> 'int-11',

+ 165 - 0
module/scm_role/lib/Order.php

@@ -0,0 +1,165 @@
+<?php
+
+namespace Scm_role\Lib;
+
+use Dever;
+
+class Order
+{
+	public function search_api()
+    {
+        $role = Dever::input('role');
+        $where = array();
+        if ($role == 'servicer_store') {
+        	$servicer = Dever::db('scm_role/servicer_store')->find(Dever::input('yes'));
+        	$where['servicer_id'] = $servicer['servicer_id'];
+        }
+        return Dever::search('scm_role/' . $role, $where);
+    }
+
+    # 获取商品列表
+    public function goods_api()
+    {
+        $id = Dever::input('id', 1);
+        $role = Dever::input('role');
+        $price_id = Dever::input('price_id', -1);
+        $type = Dever::input('type', 'in');
+        $source = '';
+        $table = '';
+        $goods_category = Dever::input('goods_category');
+        $where[$role . '_id'] = $id;
+        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList($table, $where, $goods_category, 'goods_id', array(), $price_id, $source));
+    }
+
+    # 入库下单
+    public function home_api()
+    {
+        $data = array();
+        $data['id'] = Dever::input('id', 1);
+        $data['role'] = Dever::input('role');
+        $data['type'] = Dever::input('type');
+        $info_table = $data['role'];
+        if (strstr($data['role'], '_')) {
+        	$temp = explode('_', $data['role']);
+        	$info_table = $temp[0];
+        }
+        $info = Dever::db('scm_role/' . $info_table)->find($data['id']);
+        $data['info'] = $info;
+
+        $data['host'] = Dever::url('lib/order.home', 'scm_role');
+
+        $uri = 'lib/order.goods?id=' . $data['id'] . '&role=' . $data['role'];
+
+        # 选择上游
+        if ($data['role'] == 'seller') {
+        	$data['name'] = '销售商';
+        	$data['source'] = Dever::db('scm_role/supplier')->select();
+        } elseif ($data['role'] == 'servicer_store') {
+        	$data['name'] = '仓库';
+        	$servicer = Dever::db('scm_role/servicer_store')->find($data['id']);
+        	$data['source'] = Dever::db('scm_role/servicer_supplier')->getData(array('servicer_id' => $servicer['servicer_id']));
+        }
+
+        $data['source'] = Dever::json_encode($data['source']);
+
+        if ($data['type'] == 'in') {
+        	$data['type_name'] = '入库';
+        	$data['type_config'] = array(1,2);
+        } else {
+        	$data['type_name'] = '出库';
+        }
+
+        $data['search'] = Dever::url('lib/order.search?yes='.$data['id'].'&role=' . $data['role'] . '&json=1', 'scm_role');
+
+        if (isset($info['category'])) {
+        	$uri .= '&goods_category=' . $info['category'];
+        }
+        $data['url'] = Dever::url($uri, 'scm_role');
+        $data['submit'] = Dever::url('lib/order.action_commit?json=1', 'scm_role');
+
+        return Dever::render('order_' . $data['role'], $data);
+    }
+
+    # 入库下单
+    public function action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $role = Dever::input('role');
+        $goods = Dever::json_decode($goods);
+        $id = Dever::input('id');
+
+        $col = $role . '_id';
+        $table_goods = 'scm_role/'.$role.'_goods';
+        $table_goods_sku = 'scm_role/'.$role.'_goods_sku';
+
+        $info = Dever::db('scm_role/' . $role)->one($id);
+        $where['option_' . $col] = $id;
+        $where['set_state'] = 2;
+        Dever::db($table_goods)->updates($where);
+        Dever::db($table_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;
+            }
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w[$col] = $id;
+            $w['sku_id'] = $sku_id;
+
+            if ($v['del'] == 2) {
+                $sku_info = Dever::db($table_goods_sku)->one($w);
+
+                if ($sku_info) {
+                    Dever::db($table_goods_sku)->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $t = $w;
+                $t['state'] = 1;
+                $total = Dever::db($table_goods_sku)->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db($table_goods)->one($w);
+                    if ($info) {
+                        Dever::db($table_goods)->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('scm_product/info')->one($goods_id);
+                $info = Dever::db($table_goods)->one($w);
+
+                $u = $w;
+                $u['in_num'] = $v['num'];
+                
+                if (!$info) {
+                    Dever::db($table_goods)->insert($u);
+                } else {
+                    $u['where_id'] = $info['id'];
+                    $u['state'] = 1;
+                    Dever::db($table_goods)->update($u);
+                }
+
+                $u['sku_id'] = $w['sku_id'] = $sku_id;
+                $info = Dever::db($table_goods_sku)->one($w);
+
+                if (!$info) {
+                    Dever::db($table_goods_sku)->insert($u);
+                } else {
+                    $u['where_id'] = $info['id'];
+                    $u['state'] = 1;
+                    Dever::db($table_goods_sku)->update($u);
+                }
+            }
+        }
+        return 'refer';
+    }
+}

+ 0 - 121
module/scm_role/lib/Seller.php

@@ -22,127 +22,6 @@ class Seller
         return $data;
     }
 
-    # 获取商品列表
-    public function goods_api()
-    {
-        $seller_id = Dever::input('seller_id', 1);
-        $price_id = Dever::input('price_id', -1);
-        $type = Dever::input('type', 1);
-        $source = '';
-        $table = 'scm_role/seller_goods_sku';
-        if ($type == 2) {
-            $source = 'scm_role/seller_goods_sku';
-            $table = '';
-        }
-        $goods_category = Dever::input('goods_category');
-        $where['seller_id'] = $seller_id;
-        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList($table, $where, $goods_category, 'goods_id', array(), $price_id, $source));
-    }
-
-    # 配置商品
-    public function setGoods_api()
-    {
-        $data = array();
-        $data['seller_id'] = Dever::input('id', 1);
-        $info = Dever::db('scm_role/seller')->find($data['seller_id']);
-        $data['info'] = $info;
-        $goods_category = $info['category'];
-
-        $data['host'] = Dever::url('lib/seller.setGoods', 'scm_role');
-        $data['url'] = Dever::url('lib/seller.goods?seller_id=' . $data['seller_id'] . '&goods_category=' . $goods_category . '&price_id=' . $info['price_id'], 'scm_role');
-        //$data['search'] = Dever::url('lib/seller.search?yes='.$data['seller_id'].'&json=1', 'scm_role');
-        $data['submit'] = Dever::url('lib/seller.setGoods_action_commit?json=1', 'scm_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);
-        $seller_id = Dever::input('seller_id');
-
-        $seller = Dever::db('scm_role/seller')->one($seller_id);
-        $where['option_seller_id'] = $seller_id;
-        $where['set_state'] = 2;
-        Dever::db('scm_role/seller_goods')->updates($where);
-
-        Dever::db('scm_role/seller_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['seller_id'] = $seller_id;
-                $w['sku_id'] = $sku_id;
-                $sku_info = Dever::db('scm_role/seller_goods_sku')->one($w);
-
-                if ($sku_info) {
-                    Dever::db('scm_role/seller_goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2));
-                }
-                unset($w['sku_id']);
-                $t = $w;
-                $t['state'] = 1;
-                $total = Dever::db('scm_role/seller_goods_sku')->total($t);
-                if ($total <= 0) {
-                    $info = Dever::db('scm_role/seller_goods')->one($w);
-                    if ($info) {
-                        Dever::db('scm_role/seller_goods')->update(array('where_id' => $info['id'], 'state' => 2));
-                    }
-                }
-            } else {
-                $goods_info = Dever::db('scm_product/info')->one($goods_id);
-                $w = array();
-                $w['goods_id'] = $goods_id;
-                $w['seller_id'] = $seller_id;
-                $info = Dever::db('scm_role/seller_goods')->one($w);
-
-                $w['in_num'] = $v['num'];
-                $w['min'] = $v['min'];
-                if (!$info) {
-                    Dever::db('scm_role/seller_goods')->insert($w);
-                } else {
-                    $w['in_num'] += $info['in_num'];
-                    $w['where_id'] = $info['id'];
-                    $w['state'] = 1;
-                    Dever::db('scm_role/seller_goods')->update($w);
-                }
-
-                $w = array();
-                $w['goods_id'] = $goods_id;
-                $w['seller_id'] = $seller_id;
-                $w['sku_id'] = $sku_id;
-                $info = Dever::db('scm_role/seller_goods_sku')->one($w);
-
-                $w['in_num'] = $v['num'];
-                $w['min'] = $v['min'];
-                if (!$info) {
-                    Dever::db('scm_role/seller_goods_sku')->insert($w);
-                } else {
-                    $w['in_num'] += $info['in_num'];
-                    $w['where_id'] = $info['id'];
-                    $w['state'] = 1;
-                    Dever::db('scm_role/seller_goods_sku')->update($w);
-                }
-            }
-        }
-        return 'refer';
-    }
-
     # 采购商品
     public function buyGoods_api()
     {

+ 47 - 0
module/scm_role/lib/Servicer.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace Scm_role\Lib;
+
+use Dever;
+
+class Servicer
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    public function getStore($id)
+    {
+        $table = array();
+        $table['head'] = array('仓库名称', '仓库编码', '操作');
+        $table['body'] = array();
+
+        $data = Dever::db('scm_role/servicer_store')->select(array('servicer_id' => $id));
+
+        if ($data) {
+        	$status = Dever::db('scm_role/servicer_store')->config['status'];
+            foreach ($data as $k => $v) {
+            	$status_name = '';
+            	if ($v['status'] == 2) {
+            		$status_name = '(已禁用)';
+            	}
+            	$oper = '<a class="layui-btn" href="'.Dever::url('lib/set.home?role=servicer_store&id=' . $v['id'], 'scm_role').'">商品列表</a>';
+                $table['body'][$k][] = $v['name'] . $status_name;
+                $table['body'][$k][] = $v['code'];
+                $table['body'][$k][] = $oper;
+            }
+        }
+        $body[''] = array
+        (
+            'type' => 'table',
+            'content' => $table,
+        );
+
+        if ($table['body']) {
+            return Dever::show('', $body);
+        } else {
+            return '暂无';
+        }
+    }
+}

+ 139 - 0
module/scm_role/lib/Set.php

@@ -0,0 +1,139 @@
+<?php
+
+namespace Scm_role\Lib;
+
+use Dever;
+
+class Set
+{
+    # 获取商品列表
+    public function goods_api()
+    {
+        $id = Dever::input('id', 1);
+        $role = Dever::input('role');
+        $price_id = Dever::input('price_id', -1);
+        $type = Dever::input('type', 1);
+        $source = '';
+        $table = 'scm_role/'.$role.'_goods_sku';
+        if ($type == 2) {
+            $source = $table;
+            $table = '';
+        }
+        $goods_category = Dever::input('goods_category');
+        $where[$role . '_id'] = $id;
+        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList($table, $where, $goods_category, 'goods_id', array(), $price_id, $source));
+    }
+
+    # 配置商品
+    public function home_api()
+    {
+        $data = array();
+        $data['id'] = Dever::input('id', 1);
+        $data['role'] = Dever::input('role');
+        $info = Dever::db('scm_role/' . $data['role'])->find($data['id']);
+        $data['info'] = $info;
+
+        $data['host'] = Dever::url('lib/set.home', 'scm_role');
+
+        $uri = 'lib/set.goods?id=' . $data['id'] . '&role=' . $data['role'];
+
+        if (isset($info['category'])) {
+        	$uri .= '&goods_category=' . $info['category'];
+        }
+        if (isset($info['price_id'])) {
+        	$uri .= '&price_id=' . $info['price_id'];
+        }
+        $data['url'] = Dever::url($uri, 'scm_role');
+        $data['submit'] = Dever::url('lib/set.action_commit?json=1', 'scm_role');
+
+        return Dever::render('set_' . $data['role'] . '_goods', $data);
+    }
+
+    # 配置商品
+    public function action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $role = Dever::input('role');
+        $goods = Dever::json_decode($goods);
+        $id = Dever::input('id');
+
+        $col = $role . '_id';
+        $table_goods = 'scm_role/'.$role.'_goods';
+        $table_goods_sku = 'scm_role/'.$role.'_goods_sku';
+
+        $info = Dever::db('scm_role/' . $role)->one($id);
+        $where['option_' . $col] = $id;
+        $where['set_state'] = 2;
+        Dever::db($table_goods)->updates($where);
+        Dever::db($table_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;
+            }
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w[$col] = $id;
+            $w['sku_id'] = $sku_id;
+
+            if ($v['del'] == 2) {
+                $sku_info = Dever::db($table_goods_sku)->one($w);
+
+                if ($sku_info) {
+                    Dever::db($table_goods_sku)->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $t = $w;
+                $t['state'] = 1;
+                $total = Dever::db($table_goods_sku)->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db($table_goods)->one($w);
+                    if ($info) {
+                        Dever::db($table_goods)->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('scm_product/info')->one($goods_id);
+                $info = Dever::db($table_goods)->one($w);
+
+                $u = $w;
+                if (isset($v['min'])) {
+                	$u['min'] = $v['min'];
+                }
+                if (isset($v['cost_price'])) {
+                	$u['cost_price'] = $v['cost_price'];
+                }
+                
+                if (!$info) {
+                    Dever::db($table_goods)->insert($u);
+                } else {
+                    $u['where_id'] = $info['id'];
+                    $u['state'] = 1;
+                    Dever::db($table_goods)->update($u);
+                }
+
+                $u['sku_id'] = $w['sku_id'] = $sku_id;
+                $info = Dever::db($table_goods_sku)->one($w);
+
+                if (!$info) {
+                    Dever::db($table_goods_sku)->insert($u);
+                } else {
+                    $u['where_id'] = $info['id'];
+                    $u['state'] = 1;
+                    Dever::db($table_goods_sku)->update($u);
+                }
+            }
+        }
+        return 'refer';
+    }
+}

+ 76 - 90
module/scm_role/lib/Supplier.php

@@ -11,117 +11,103 @@ class Supplier
         Dever::load('manage/auth.init');
     }
 
-    # 获取门店
+    # 获取下游
     public function search_api()
     {
-        return Dever::search('scm_product/category', array(), 'getTop');
+        $role = Dever::input('role');
+        return Dever::search('scm_role/' . $role);
     }
 
-    # 获取商品列表
-    public function goods_api()
+    # 分配供应商
+    public function get_api()
     {
-        $supplier_id = Dever::input('supplier_id', 1);
-        $goods_category = Dever::input('goods_category');
-        $where['supplier_id'] = $supplier_id;
-        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList('scm_role/supplier_goods_sku', $where, $goods_category));
+        $role = Dever::input('role');
+        $id = Dever::input('id', 1);
+        $data = Dever::db('scm_role/'.$role.'_supplier')->getAll(array($role . '_id' => $id));
+        $type = Dever::db('scm_role/supplier_type')->select();
+        
+        $result = array();
+        if ($type) {
+            $i = 0;
+            foreach ($type as $k => $v) {
+                $supplier = Dever::db('scm_role/supplier')->select(array('status' => 1, 'type_id' => $v['id']));
+                if ($supplier) {
+                    $result[$i] = array();
+                    $result[$i]['id'] = $v['id'];
+                    $result[$i]['name'] = $v['name'];
+                    $result[$i]['select'] = 2;
+                    $result[$i]['end'] = false;
+                    $result[$i]['children'] = array();
+
+                    foreach ($supplier as $k1 => $v1) {
+                        $child = array();
+                        $child['id'] = $v1['id'];
+                        $child['name'] = $v1['name'];
+                        $child['code'] = $v1['code'];
+                        $child['type_name'] = $v['name'];
+                        $child['select'] = 2;
+                        $child['end'] = true;
+                        if (isset($data[$v1['id']]) && $data[$v1['id']]) {
+                            $child['select'] = 1;
+                        }
+                        $result[$i]['children'][] = $child;
+                    }
+                    $i++;
+                }
+            }
+        }
+        return Dever::outDiy($result);
     }
 
-    # 配置商品
-    public function setGoods_api()
+    public function set_api()
     {
         $data = array();
-        $data['supplier_id'] = Dever::input('id', 1);
-        $info = Dever::db('scm_role/supplier')->find($data['supplier_id']);
-        $data['info'] = $info;
-        $goods_category = $info['category'];
-
-        $data['host'] = Dever::url('lib/supplier.setGoods', 'scm_role');
-        $data['url'] = Dever::url('lib/supplier.goods?supplier_id=' . $data['supplier_id'] . '&goods_category=' . $goods_category, 'scm_role');
-        //$data['search'] = Dever::url('lib/supplier.search?yes='.$data['supplier_id'].'&json=1', 'scm_role');
-        $data['submit'] = Dever::url('lib/supplier.setGoods_action_commit?json=1', 'scm_role');
+        $data['id'] = Dever::input('id', 1);
+        $data['role'] = Dever::input('role');
+        if ($data['role'] == 'seller') {
+            $data['name'] = '销售商';
+        } else {
+            $data['name'] = '配送商';
+        }
+        $data['host'] = Dever::url('lib/supplier.set?role=' . $data['role'], 'scm_role');
+        $data['url'] = Dever::url('lib/supplier.get?id=' . $data['id'] . '&role=' . $data['role'], 'scm_role');
+        $data['search'] = Dever::url('lib/supplier.search?yes='.$data['id'].'&role=' . $data['role'] . '&json=1', 'scm_role');
+        $data['submit'] = Dever::url('lib/supplier.set_commit?json=1', 'scm_role');
 
-        return Dever::render('set_supplier_goods', $data);
+        return Dever::render('set_supplier', $data);
     }
 
-    # 配置商品
-    public function setGoods_action_commit_api()
+    public function set_commit_api()
     {
-        $goods = Dever::input('goods');
-        if (!$goods) {
-            Dever::alert('请传入商品');
+        $value = Dever::input('value');
+        if (!$value) {
+            Dever::alert('未选择');
         }
-        $goods = Dever::json_decode($goods);
-        $supplier_id = Dever::input('supplier_id');
+        $value = Dever::json_decode($value);
+        $id = Dever::input('id');
+        $role = Dever::input('role');
 
-        $supplier = Dever::db('scm_role/supplier')->one($supplier_id);
-        $where['option_supplier_id'] = $supplier_id;
+        $col = $role . '_id';
+        $table = 'scm_role/' . $role . '_supplier';
+        $where['option_' . $col] = $id;
         $where['set_state'] = 2;
-        Dever::db('scm_role/supplier_goods')->updates($where);
+        Dever::db($table)->updates($where);
 
-        Dever::db('scm_role/supplier_goods_sku')->updates($where);
+        foreach ($value as $k => $v) {
+            $w = array();
+            $w['supplier_id'] = $v['id'];
+            $w[$col] = $id;
+            $info = Dever::db($table)->one($w);
 
-        foreach ($goods as $k => $v) {
-            $temp = explode('-', $k);
-            $goods_id = $temp[0];
-            if (isset($temp[1])) {
-                $sku_id = $temp[1];
+            if (!$info) {
+                Dever::db($table)->insert($w);
             } else {
-                $sku_id = -1;
-            }
-            if ($v['num'] < 0) {
-            	continue;
-            }
-            if ($v['del'] == 2) {
-                $w = array();
-                $w['goods_id'] = $goods_id;
-                $w['supplier_id'] = $supplier_id;
-                $w['sku_id'] = $sku_id;
-                $sku_info = Dever::db('scm_role/supplier_goods_sku')->one($w);
-
-                if ($sku_info) {
-                    Dever::db('scm_role/supplier_goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2));
-                }
-                unset($w['sku_id']);
-                $t = $w;
-                $t['state'] = 1;
-                $total = Dever::db('scm_role/supplier_goods_sku')->total($t);
-                if ($total <= 0) {
-                    $info = Dever::db('scm_role/supplier_goods')->one($w);
-                    if ($info) {
-                        Dever::db('scm_role/supplier_goods')->update(array('where_id' => $info['id'], 'state' => 2));
-                    }
-                }
-            } else {
-                $goods_info = Dever::db('scm_product/info')->one($goods_id);
-                $w = array();
-                $w['goods_id'] = $goods_id;
-                $w['supplier_id'] = $supplier_id;
-                $info = Dever::db('scm_role/supplier_goods')->one($w);
-                if (!$info) {
-                    Dever::db('scm_role/supplier_goods')->insert($w);
-                } else {
-                    $w['where_id'] = $info['id'];
-                    $w['state'] = 1;
-                    Dever::db('scm_role/supplier_goods')->update($w);
-                }
-
-                $w = array();
-                $w['goods_id'] = $goods_id;
-                $w['supplier_id'] = $supplier_id;
-                $w['sku_id'] = $sku_id;
-                $info = Dever::db('scm_role/supplier_goods_sku')->one($w);
-
-                $w['in_num'] = $v['num'];
-                if (!$info) {
-                    Dever::db('scm_role/supplier_goods_sku')->insert($w);
-                } else {
-                    $w['in_num'] += $info['in_num'];
-                    $w['where_id'] = $info['id'];
-                    $w['state'] = 1;
-                    Dever::db('scm_role/supplier_goods_sku')->update($w);
-                }
+                $w['where_id'] = $info['id'];
+                $w['state'] = 1;
+                Dever::db($table)->update($w);
             }
         }
+
         return 'refer';
     }
 }

+ 157 - 0
module/scm_seller/database/goods.php

@@ -0,0 +1,157 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'goods',
+    # 显示给用户看的名称
+    'lang' => '销售商商品列表',
+    'order' => 10,
+    'menu'  => false,
+
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.goodsUpdate',
+        'update' => 'scm_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("scm_seller/info-one#name", {seller_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_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' => 'scm_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' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,cdate',
+        ),
+
+        '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' => 'scm_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' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,t_1.cdate,t_1.id as id',
+        ),
+    ),
+);

+ 317 - 0
module/scm_seller/database/goods_sku.php

@@ -0,0 +1,317 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'goods_sku',
+    # 显示给用户看的名称
+    'lang' => '商品价格设置',
+    'order' => 200,
+    'menu' => false,
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.skuUpdate',
+        'update' => 'scm_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("scm_seller/info-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' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'in_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库库存',
+            'default'   => '0',
+            'desc'      => '入库库存',
+            'match'     => 'is_numeric',
+        ),
+
+        'out_num'      => array
+        (
+            'type'      => 'decimal-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,
+        ),
+
+        '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.in_num-t_1.out_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' => 'scm_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(30, 'list'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_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.in_num-t_1.out_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' => 'scm_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.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num,t_1.in_num,t_2.type,t_2.stock,t_2.commission,t_2.sell_type,t_2.buy_type',
+        ),
+
+       	# 列表
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*,in_num-out_num as total|sku_id',
+        ),
+
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*,in_num-out_num as total',
+        ),
+
+        # 更新售出量
+        'incSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少售出量
+        'decSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '-='),
+            ),
+        ),
+
+        # 更新总库存
+        'updateTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 增加总库存
+        'incTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少总库存
+        'decTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '-='),
+            ),
+        ),
+    ),
+);
+
+return $config;

+ 478 - 0
module/scm_seller/database/info.php

@@ -0,0 +1,478 @@
+<?php
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('scm_seller/type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$seller = function()
+{
+	$array = array();
+	$data = Dever::load('scm_seller/info-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('scm_product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$price = function()
+{
+    $array = array
+    (
+        -1 => '默认模板',
+    );
+    $data = Dever::load('scm_product/price-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+
+$sell_goods = array
+(
+	1 => '经销所有商品',
+	2 => '经销部分商品',
+);
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+$stock = array
+(
+	1 => '独立库存',
+	2 => '共享库存',
+);
+
+$status = array
+(
+    1 => '启用',
+    2 => '禁用',
+);
+
+$account = function() {
+    return Dever::load('account/api')->getConfig('scm_seller/info');
+};
+
+return array
+(
+	# 表名
+	'name' => 'seller',
+	# 显示给用户看的名称
+	'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,
+		),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '经销商编码',
+            'default'   => '',
+            'desc'      => '经销商编码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+		'info'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '经销商介绍',
+            'default'   => '',
+            'desc'      => '经销商介绍',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+		'type_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '经销商类型',
+            'default'   => '1',
+            'desc'      => '经销商类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'		=> true,
+        ),
+
+        'account'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '选择账户',
+            'default'   => '',
+            'desc'      => '选择账户',
+            'match'     => 'is_string',
+            'update'    => 'checkbox',
+            'option'    => $account,
+            'list_name' => '账户信息',
+            'list'      => 'Dever::load("account/api.getInfo", {id}, "{account}")',
+        ),
+
+        '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'
+        ),
+
+        'category'		=> array
+		(
+			'type' 		=> 'varchar-2000',
+			'name' 		=> '商品属性分类-如不选择就是可以销售所有商品属性分类下的商品',
+			'default' 	=> '',
+			'desc' 		=> '商品属性分类',
+			'match' 	=> 'is_string',
+			'update'	=> 'checkbox',
+			'option'	=> $category,
+            'show'      => 'stock=1'
+		),
+
+        'price_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品价格模板',
+            'default'   => '-1',
+            'desc'      => '商品价格模板',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $price,
+            'show'      => 'stock=1'
+        ),
+
+        'commission'        => array
+        (
+            'type'      => 'varchar-20',
+            'name'      => '销售佣金调整-针对每个商品的销售佣金做统一调整,如填写5%,就是在原有销售佣金的基础上增加5%佣金,不设置则不做任何调整,设置为0,则佣金为0',
+            'default'   => '0',
+            'desc'      => '销售佣金调整',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+		'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,
+		),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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
+	(
+        'delete' => false,
+		'tab' => array('基本设置', '联系人信息', '认证信息'),
+		'button' => array
+        (
+            //'类型配置' => array('list', 'type&oper_parent=seller'),
+        ),
+        'list_button' => array
+        (
+        	'location' => array('商品设置', Dever::url('lib/set.home?role=seller', 'scm_product'), '{stock} == 1'),
+            'br3' => array('<br />'),
+            'location1' => array('订货下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
+            'location2' => array('入库下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
+            'location3' => array('出库下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
+            'br4' => array('<br />'),
+            'fast_add' => array('账户操作', 'push&project=account&oper_table=info&oper_project=scm_seller&uid={id}', '{account}'),
+            'list' => array('账户流水', 'info_log&project=account&oper_table=info&oper_project=scm_seller&search_option_uid={id}', '{account}'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,code,type_id,state,cdate',
+		'value' => array
+		(
+			'"平台经销商", "platform", 1, 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		'like' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*|id',
+        ),
+	)
+);

+ 105 - 0
module/scm_seller/database/type.php

@@ -0,0 +1,105 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'type',
+	# 显示给用户看的名称
+	'lang' => '经销商类型',
+	# 是否显示在后台菜单
+	'order' => 1,
+
+	# 数据结构
+	'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
+	(
+		'insert' => false,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"平台自营", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 8 - 0
module/scm_seller/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'scm_seller');
+define('DEVER_APP_LANG', '经销商');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 92);
+define('DEVER_MANAGE_ICON', 'layui-icon-username');
+include(DEVER_APP_PATH . '../boot.php');

+ 193 - 0
module/scm_servicer/database/in_order.php

@@ -0,0 +1,193 @@
+<?php
+
+$status = array
+(
+    1 => '待审核',
+    2 => '已审核',
+    3 => '已驳回',
+);
+
+$store = array();
+$servicer_id = Dever::input('search_option_servicer_id');
+if ($servicer_id) {
+	$store = function() use($servicer_id) {
+		return Dever::db('scm_servicer/store')->select(array('servicer_id' => $servicer_id));
+	};
+}
+
+$supplier = function() use($servicer_id) {
+	return Dever::db('scm_servicer/supplier')->getData(array('servicer_id' => $servicer_id));
+};
+
+return array
+(
+    # 表名
+    'name' => 'in_order',
+    # 显示给用户看的名称
+    'lang' => '入库单查询',
+    'order' => 9,
+    'set' => array
+    (
+    	'status' => $status,
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单号',
+            'default'   => '',
+            'desc'      => '订单号',
+            'match'     => 'is_string',
+            'search'    => 'fulltext',
+            'list_name'	=> '订单信息',
+            //'list'      => 'Dever::load("scm_order/lib/sell.info#order", {id})',
+        ),
+
+        'servicer_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '配送商ID',
+            'default'   => '',
+            'desc'      => '配送商ID',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'searchs'    => array
+            (
+                'api' => 'scm_role/seller-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'value'     => $servicer_id,
+        ),
+
+        'servicer_store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '仓库',
+            'default'   => '',
+            'desc'      => '仓库',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $store,
+            'list'		=> true,
+        ),
+
+        'supplier_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '供应商',
+            'default'   => '',
+            'desc'      => '供应商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $supplier,
+            'list'		=> true,
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单备注',
+            'default'   => '',
+            'desc'      => '订单备注',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            //'search_after' => '<br />',
+            //'mul'   => true,
+            //'mul_option' => array(2 => '批量审核', 5 => '确认收货'),
+        ),
+
+        'scm_servicer-in_order_goods'=> array
+		(
+			'name' 		=> '商品设置',
+			'default' 	=> '',
+			'desc' 		=> '商品设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'order_id'),
+			'update'	=> array(1),
+			# 1纵向展示 2横向展示
+			'update_type' => 2,
+			//'list'		=> 'Dever::load("scm_servicer/lib/manage.getStore", {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'    => 'sdate',
+            'list'        => 'date("Y-m-d H:i", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        //'excel' => $excel,
+        //'mul' => $mul,
+
+        'button' => array
+        (
+            //'导出订单明细' => array('excel', 'shop/excel.sell_order'),
+        ),
+
+        'list_button' => array
+        (
+            //fast_list
+            /*
+            'list' => array('查看详情', '"sell_order_goods&project=shop&order_id={id}&page_type=&search_option_shop_type='.$search_option_shop_type.'"'),
+
+            'list11' => array('查看采购单', '"buy_order&project=shop&search_option_type=1&&search_option_parent_type=2&search_option_parent_order_id={id}&oper_table=sell_order&search_option_shop_type='.$search_option_shop_type.'"', '{status} >= 3 && {audit} == 2 && {shop_type} == 2'),
+
+            'list1' => array('审核', '"sell_order_goods&project=shop&order_id={id}&audit=1&page_type=&search_option_shop_type='.$search_option_shop_type.'"', '{status} == 2 && {shop_type} == 2'),
+
+            'oper'  => array('确认收货', '"shop/lib/manage.setSellOrderStatus?shop_id={shop_id}&order_id={id}"', '{status} == 4 && {shop_type} == 2'),
+            */
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 173 - 0
module/scm_servicer/database/in_order_goods.php

@@ -0,0 +1,173 @@
+<?php
+
+$status = array
+(
+    1 => '正常',
+    2 => '申请退款中',
+    3 => '已退款',
+);
+
+return array
+(
+    # 表名
+    'name' => 'in_order_goods',
+    # 显示给用户看的名称
+    'lang' => '订单商品表',
+    'menu' => false,
+    'status' => $status,
+    'end' => array
+    (
+        'insert' => 'scm_servicer/lib/manage.updateGoods?table=in_order_goods',
+        'update' => 'scm_servicer/lib/manage.updateGoods?table=in_order_goods',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'goods'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '商品',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'option',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.searchProduct?{id}',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'is_numeric',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
+            'match'     => 'is_numeric',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '单价',
+            'default'   => '',
+            'desc'      => '单价',
+            'match'     => 'option',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '数量',
+            'default'   => '1',
+            'desc'      => '数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'	=> 'text',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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
+    (
+        'insert' => false,
+        'delete' => false,
+    ),
+
+    'request' => array
+    (
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-t_2.cdate', '>='),
+                'end' => array('yes-t_2.cdate', '<='),
+                'start_o' => array('yes-t_2.operdate', '>='),
+                'end_o' => array('yes-t_2.operdate', '<='),
+                'servicer_id' => array('yes-t_2.servicer_id'),
+                'servicer_store_id' => array('yes-t_2.servicer_store_id'),
+                'goods_id' => array('yes-t_1.goods_id'),
+                'status' => array('yes-t_2.status', 'in'),
+                'state_2' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+                'status_1' => 'yes-t_1.status-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_servicer/in_order',
+                    'type' => 'left join',
+                    'on' => array('order_id','id'),
+                ),
+            ),
+            'type' => 'all',
+            'group' => 't_2.servicer_id, t_2.servicer_store_id, t_1.goods_id',
+            'col' => 'id,t_2.servicer_id, t_2.servicer_store_id, t_1.goods_id,sum(t_1.num) as num',
+        ),
+    ),
+);

+ 348 - 0
module/scm_servicer/database/info.php

@@ -0,0 +1,348 @@
+<?php
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('scm_product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+$status = array
+(
+    1 => '启用',
+    2 => '禁用',
+);
+
+return array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '配送商列表',
+	# 是否显示在后台菜单
+	'order' => 10,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+			//'order'		=> 'desc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '配送商名称',
+			'default' 	=> '',
+			'desc' 		=> '配送商名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'code'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '配送商编码',
+            'default'   => '',
+            'desc'      => '配送商编码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'category'      => array
+        (
+            'type'      => 'varchar-2000',
+            'name'      => '商品属性分类-如不选择就是可以选择所有商品属性分类下的商品',
+            'default'   => '',
+            'desc'      => '商品属性分类',
+            'match'     => 'is_string',
+            'update'    => 'checkbox',
+            'option'    => $category,
+        ),
+
+		'scm_servicer-store'=> array
+		(
+			'name' 		=> '仓库设置',
+			'default' 	=> '',
+			'desc' 		=> '仓库设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'servicer_id'),
+			'update'	=> array(1),
+			# 1纵向展示 2横向展示
+			'update_type' => 2,
+			'list'		=> 'Dever::load("scm_servicer/lib/manage.getStore", {id})',
+		),
+
+		'truename'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '联系人姓名',
+            'default'   => '',
+            'desc'      => '请输入联系人姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'tel'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人电话',
+            'default'   => '',
+            'desc'      => '请输入联系人电话',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'email'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人邮箱',
+            'default'   => '',
+            'desc'      => '联系人邮箱',
+            'match'     => 'option',
+            '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,
+		),
+
+		'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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('基本设置', '联系人信息', '认证信息'),
+		'delete' => false,
+		'list_button' => array
+        (
+        	'location' => array('供应商', Dever::url('lib/set.home?role=servicer', 'scm_supplier')),
+            'br3' => array('<br />'),
+            'add' => array('入库下单', 'in_order&oper_table=info&search_option_servicer_id={id}&oper_save_jump=info'),
+            'add2' => array('出库下单', 'out_order&oper_table=info&search_option_servicer_id={id}&oper_save_jump=info'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,code,state,cdate',
+		'value' => array
+		(
+			'"默认配送商", "default", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 130 - 0
module/scm_servicer/database/store.php

@@ -0,0 +1,130 @@
+<?php
+
+$status = array
+(
+	1 => '启用',
+	2 => '禁用',
+);
+return array
+(
+	# 表名
+	'name' => 'store',
+	# 显示给用户看的名称
+	'lang' => '配送商仓库',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	'status' => $status,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'servicer_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '配送商ID',
+			'default' 	=> '-1',
+			'desc' 		=> '配送商ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_servicer_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '仓库名称',
+			'default' 	=> '',
+			'desc' 		=> '仓库名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'code'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '仓库编码',
+            'default'   => '',
+            'desc'      => '仓库编码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否启用',
+			'default' 	=> '1',
+			'desc' 		=> '是否启用',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $status,
+			'list'		=> true,
+			'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
+	(
+		'delete' => false,
+        
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 149 - 0
module/scm_servicer/database/store_goods.php

@@ -0,0 +1,149 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'store_goods',
+    # 显示给用户看的名称
+    'lang' => '仓库商品列表',
+    'order' => 10,
+    'menu'  => false,
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'servicer_store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属配送商',
+            'default'   => '',
+            'desc'      => '所属配送商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_servicer_store_id'),
+            'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_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
+            (
+                'servicer_store_id' => array('yes-t_1.servicer_store_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' => 'scm_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' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,cdate',
+        ),
+
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'servicer_store_id' => array('yes-t_1.servicer_store_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' => 'scm_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' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,t_1.cdate,t_1.id as id',
+        ),
+    ),
+);

+ 300 - 0
module/scm_servicer/database/store_goods_sku.php

@@ -0,0 +1,300 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'servicer_store_goods_sku',
+    # 显示给用户看的名称
+    'lang' => '商品价格设置',
+    'order' => 200,
+    'menu' => false,
+
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'servicer_store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属配送商',
+            'default'   => '',
+            'desc'      => '所属配送商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_servicer_store_id'),
+            'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_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' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'in_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库库存',
+            'default'   => '0',
+            'desc'      => '入库库存',
+            'match'     => 'is_numeric',
+        ),
+
+        'out_num'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '出库库存',
+            'default'   => '0',
+            'desc'      => '出库库存',
+            'match'     => 'option',
+        ),
+
+        '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
+            (
+                'servicer_store_id' => array('yes-t_1.servicer_store_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.in_num-t_1.out_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' => 'scm_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(30, 'list'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'servicer_store_id' => array('yes-t_1.servicer_store_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.in_num-t_1.out_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' => 'scm_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.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num,t_1.in_num,t_2.type,t_2.stock,t_2.commission,t_2.sell_type,t_2.buy_type',
+        ),
+
+       	# 列表
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*,in_num-out_num as total|sku_id',
+        ),
+
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*,in_num-out_num as total',
+        ),
+
+        # 更新售出量
+        'incSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少售出量
+        'decSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '-='),
+            ),
+        ),
+
+        # 更新总库存
+        'updateTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 增加总库存
+        'incTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少总库存
+        'decTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '-='),
+            ),
+        ),
+    ),
+);
+
+return $config;

+ 115 - 0
module/scm_servicer/database/supplier.php

@@ -0,0 +1,115 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'supplier',
+    # 显示给用户看的名称
+    'lang' => '配送商供应商关系表',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'servicer_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '配送商ID',
+			'default' 	=> '-1',
+			'desc' 		=> '配送商ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_servicer_id'),
+		),
+
+        'supplier_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '供应商ID',
+            'default'   => '',
+            'desc'      => '供应商ID',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_supplier_id'),
+            'list'      => 'Dever::load("scm_supplier/info-one#name", {supplier_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
+    (
+        
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            'option' => array
+            (
+                'servicer_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*|supplier_id',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'servicer_id' => array('yes-t_1.servicer_id'),
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_supplier/info',
+                    'type' => 'left join',
+                    'on' => array('supplier_id','id'),
+                    'col' => 'supplier_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'col' => '*,t_2.name',
+        ),
+    ),
+);

+ 8 - 0
module/scm_servicer/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'scm_servicer');
+define('DEVER_APP_LANG', '配送商');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 91);
+define('DEVER_MANAGE_ICON', 'layui-icon-template-1');
+include(DEVER_APP_PATH . '../boot.php');

+ 60 - 0
module/scm_servicer/lib/Manage.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace Scm_servicer\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    public function getStore($id)
+    {
+        $table = array();
+        $table['head'] = array('仓库名称', '仓库编码', '操作');
+        $table['body'] = array();
+
+        $data = Dever::db('scm_servicer/store')->select(array('servicer_id' => $id));
+
+        if ($data) {
+        	$status = Dever::db('scm_servicer/store')->config['status'];
+            foreach ($data as $k => $v) {
+            	$status_name = '';
+            	if ($v['status'] == 2) {
+            		$status_name = '(已禁用)';
+            	}
+            	$oper = '<a class="layui-btn" href="'.Dever::url('lib/set.home?role=servicer/store&id=' . $v['id'], 'scm_product').'">商品列表</a>';
+                $table['body'][$k][] = $v['name'] . $status_name;
+                $table['body'][$k][] = $v['code'];
+                $table['body'][$k][] = $oper;
+            }
+        }
+        $body[''] = array
+        (
+            'type' => 'table',
+            'content' => $table,
+        );
+
+        if ($table['body']) {
+            return Dever::show('', $body);
+        } else {
+            return '暂无';
+        }
+    }
+
+    public function updateGoods($id, $name, $data)
+    {
+    	$table = Dever::input('table');
+        $goods = Dever::param('goods', $data);
+        $temp = explode('-', $goods);
+        $update['where_id'] = $id;
+        $update['goods_id'] = $temp[0];
+        $update['sku_id'] = $temp[1];
+        Dever::db('scm_servicer/' . $table)->update($update);
+
+        Dever::config('base')->hook = false;
+    }
+}

+ 341 - 0
module/scm_supplier/assets/pc/html/set_supplier.html

@@ -0,0 +1,341 @@
+<!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>选择<{$name}>:</label>
+                    <div class="layui-input-inline">
+
+                        <div><select xm-select="sid" 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="sid" id="sid"  ></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>
+                <div class="goods_list" style="height:645px;">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <th lay-data="{field:'id'}">供应商ID</th>
+                                <th lay-data="{field:'id'}">供应商编码</th>
+                                <th lay-data="{field:'name'}">供应商名称</th>
+                                <th lay-data="{field:'name'}">供应商类型</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>】
+                </div>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认分配">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    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;
+    });
+
+    $(function()
+    {
+        $("#settlement").click(function(){
+            var url = '<{$submit}>';
+            var id = '<{$id}>';
+            var role = '<{$role}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {id:id, role:role, value: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);
+                    }
+                });
+            });
+        })
+    })
+    var goods = {};
+    var del_goods = {};
+    mini.parse();
+    var 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 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 setGoods(node)
+    {
+        if (node.id) {
+            var key = node.id;
+            if (!goods[key]) {
+                goods[key] = node;
+                create(node);
+                setTotal();
+            } else {
+                add(key);
+            }
+        }
+    }
+
+    function unsetGoods(node)
+    {
+        if (node.id) {
+            if (goods[node.id]) {
+                delete goods[node.id];
+                get(node.id).remove();
+            }
+        }
+    }
+
+    function get(key)
+    {
+        return $('#goods_' + key);
+    }
+
+    function create(node)
+    {
+        if (!get(node.id).length) {
+            var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
+            addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_id">'+node.code+'</td>';
+            addtr += '<td class="goods_name">'+node.name+'</td>';     
+            addtr += '<td class="goods_name">'+node.type_name+'</td>';     
+            addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';        
+            addtr += '</tr>';
+            $("#goods").append(addtr);
+        }
+    }
+
+    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 del(id)
+    {
+        if (confirm('确定删除吗?')) {
+            delete goods[id];
+			get(id).remove();
+			setTotal();
+        }
+    }
+
+    // 一键添加
+    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 setTotal()
+    {
+        var num = 0;
+        for (var i in goods) {
+            num += 1;
+        }
+        $(".totalNum").html(num);
+    }
+
+    function setShop()
+    {
+        var sid = $('.xm-select-parent[fs_id="sid"] span[fsw="xm-select"]').attr('value');
+        if (!sid) {
+            layui.layer.alert('请选择<{$name}>');
+            return;
+        }
+        layui.layer.confirm('确定切换<{$name}>吗?', function() {
+            location.href = '<{$host}>&id=' + sid;
+        });
+    }
+</script>
+</body>
+</html>

+ 155 - 0
module/scm_supplier/database/goods.php

@@ -0,0 +1,155 @@
+<?php
+$status = Dever::config('base')->status;
+return array
+(
+    # 表名
+    'name' => 'goods',
+    # 显示给用户看的名称
+    'lang' => '供应商商品列表',
+    'order' => 10,
+    'menu'  => false,
+
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.goodsUpdate',
+        'update' => 'scm_role/lib/seller.goodsUpdate',
+    ),
+    */
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'supplier_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属供应商',
+            'default'   => '',
+            'desc'      => '所属供应商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_supplier_id'),
+            'list'      => 'Dever::load("scm_supplier/info-one#name", {supplier_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_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
+            (
+                'supplier_id' => array('yes-t_1.supplier_id'),
+                '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' => 'scm_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
+            (
+                'supplier_id' => array('yes-t_1.supplier_id'),
+                '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' => 'scm_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.*',
+        ),
+    ),
+);

+ 317 - 0
module/scm_supplier/database/goods_sku.php

@@ -0,0 +1,317 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'goods_sku',
+    # 显示给用户看的名称
+    'lang' => '商品价格设置',
+    'order' => 200,
+    'menu' => false,
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.skuUpdate',
+        'update' => 'scm_role/lib/seller.skuUpdate',
+    ),
+    */
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'supplier_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属供应商',
+            'default'   => '',
+            'desc'      => '所属供应商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_supplier_id'),
+            'list'      => 'Dever::load("scm_supplier/info-one#name", {supplier_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' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'cost_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '成本价',
+            'default'   => '',
+            'desc'      => '成本价',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'in_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库库存',
+            'default'   => '0',
+            'desc'      => '入库库存',
+            'match'     => 'is_numeric',
+        ),
+
+        'out_num'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '出库库存',
+            'default'   => '0',
+            'desc'      => '出库库存',
+            'match'     => 'option',
+        ),
+
+        '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
+            (
+                'supplier_id' => array('yes-t_1.supplier_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.in_num-t_1.out_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' => 'scm_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.in_num-t_1.out_num as total,t_1.out_num',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'supplier_id' => array('yes-t_1.supplier_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.in_num-t_1.out_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' => 'scm_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.in_num-t_1.out_num as total,t_1.out_num',
+        ),
+
+       	# 列表
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'supplier_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*,in_num-out_num as total|sku_id',
+        ),
+
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'supplier_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*,in_num-out_num as total',
+        ),
+
+        # 更新售出量
+        'incSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'supplier_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少售出量
+        'decSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'supplier_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '-='),
+            ),
+        ),
+
+        # 更新总库存
+        'updateTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 增加总库存
+        'incTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'supplier_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少总库存
+        'decTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'supplier_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '-='),
+            ),
+        ),
+    ),
+);
+
+return $config;

+ 359 - 0
module/scm_supplier/database/info.php

@@ -0,0 +1,359 @@
+<?php
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('scm_supplier/type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('scm_product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+$status = array
+(
+    1 => '启用',
+    2 => '禁用',
+);
+
+return array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'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,
+		),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '供应商编码',
+            'default'   => '',
+            'desc'      => '供应商编码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+		'type_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '供应商类型',
+            'default'   => '1',
+            'desc'      => '供应商类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'      => true,
+        ),
+
+        'category'		=> array
+		(
+			'type' 		=> 'varchar-2000',
+			'name' 		=> '商品属性分类-如不选择就是可以销售所有商品属性分类下的商品',
+			'default' 	=> '',
+			'desc' 		=> '商品属性分类',
+			'match' 	=> 'is_string',
+			'update'	=> 'checkbox',
+			'option'	=> $category,
+		),
+
+		'truename'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '联系人姓名',
+            'default'   => '',
+            'desc'      => '请输入联系人姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'tel'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人电话',
+            'default'   => '',
+            'desc'      => '请输入联系人电话',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'email'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人邮箱',
+            'default'   => '',
+            'desc'      => '联系人邮箱',
+            'match'     => 'option',
+            '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,
+		),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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
+	(
+        'delete' => false,
+		'tab' => array('基本设置', '联系人信息', '认证信息'),
+		'button' => array
+        (
+            //'类型配置' => array('list', 'type&oper_parent=info'),
+        ),
+        'list_button' => array
+        (
+        	'location' => array('商品设置', Dever::url('lib/set.home?role=supplier', 'scm_product')),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,code,type_id,state,cdate',
+		'value' => array
+		(
+			'"默认供应商", "default", 1, 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 3 - 4
module/scm_role/database/servicer_type.php → module/scm_supplier/database/type.php

@@ -3,12 +3,11 @@
 return array
 (
 	# 表名
-	'name' => 'servicer_type',
+	'name' => 'type',
 	# 显示给用户看的名称
 	'lang' => '供应商类型',
 	# 是否显示在后台菜单
-	'order' => 10,
-	'menu' => false,
+	'order' => 1,
 
 	# 数据结构
 	'struct' => array
@@ -95,7 +94,7 @@ return array
 		'col' => 'name,state,cdate',
 		'value' => array
 		(
-			'"仓库", 1,' . DEVER_TIME,
+			'"默认类型", 1,' . DEVER_TIME,
 		),
 	),
 

+ 8 - 0
module/scm_supplier/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'scm_supplier');
+define('DEVER_APP_LANG', '供应商');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 90);
+define('DEVER_MANAGE_ICON', 'layui-icon-flag');
+include(DEVER_APP_PATH . '../boot.php');

+ 112 - 0
module/scm_supplier/lib/Set.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace Scm_supplier\Lib;
+
+use Dever;
+
+class Set
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取下游
+    public function search_api()
+    {
+        $role = Dever::input('role');
+        return Dever::search('scm_' . $role . '/info');
+    }
+
+    # 分配供应商
+    public function getList_api()
+    {
+        $role = Dever::input('role');
+        $id = Dever::input('id', 1);
+        $data = Dever::db('scm_'.$role.'/supplier')->getAll(array($role . '_id' => $id));
+        $type = Dever::db('scm_supplier/type')->select();
+        
+        $result = array();
+        if ($type) {
+            $i = 0;
+            foreach ($type as $k => $v) {
+                $supplier = Dever::db('scm_supplier/info')->select(array('status' => 1, 'type_id' => $v['id']));
+                if ($supplier) {
+                    $result[$i] = array();
+                    $result[$i]['id'] = $v['id'];
+                    $result[$i]['name'] = $v['name'];
+                    $result[$i]['select'] = 2;
+                    $result[$i]['end'] = false;
+                    $result[$i]['children'] = array();
+
+                    foreach ($supplier as $k1 => $v1) {
+                        $child = array();
+                        $child['id'] = $v1['id'];
+                        $child['name'] = $v1['name'];
+                        $child['code'] = $v1['code'];
+                        $child['type_name'] = $v['name'];
+                        $child['select'] = 2;
+                        $child['end'] = true;
+                        if (isset($data[$v1['id']]) && $data[$v1['id']]) {
+                            $child['select'] = 1;
+                        }
+                        $result[$i]['children'][] = $child;
+                    }
+                    $i++;
+                }
+            }
+        }
+        return Dever::outDiy($result);
+    }
+
+    public function home_api()
+    {
+        $data = array();
+        $data['id'] = Dever::input('id', 1);
+        $data['role'] = Dever::input('role');
+        $data['name'] = '销售商';
+        if ($data['role'] == 'servicer') {
+            $data['name'] = '配送商';
+        }
+        $data['host'] = Dever::url('lib/set.home?role=' . $data['role'], 'scm_supplier');
+        $data['url'] = Dever::url('lib/set.getList?id=' . $data['id'] . '&role=' . $data['role'], 'scm_supplier');
+        $data['search'] = Dever::url('lib/set.search?yes='.$data['id'].'&role=' . $data['role'] . '&json=1', 'scm_supplier');
+        $data['submit'] = Dever::url('lib/set.set_commit?json=1', 'scm_supplier');
+
+        return Dever::render('set_supplier', $data);
+    }
+
+    public function set_commit_api()
+    {
+        $value = Dever::input('value');
+        if (!$value) {
+            Dever::alert('未选择');
+        }
+        $value = Dever::json_decode($value);
+        $id = Dever::input('id');
+        $role = Dever::input('role');
+
+        $col = $role . '_id';
+        $table = 'scm_' . $role . '/supplier';
+        $where['option_' . $col] = $id;
+        $where['set_state'] = 2;
+        Dever::db($table)->updates($where);
+
+        foreach ($value as $k => $v) {
+            $w = array();
+            $w['supplier_id'] = $v['id'];
+            $w[$col] = $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';
+    }
+}