rabin před 2 roky
rodič
revize
4bc8420367
49 změnil soubory, kde provedl 4129 přidání a 567 odebrání
  1. 221 0
      lib/Assign.php
  2. 142 18
      lib/Order.php
  3. 29 16
      lib/Stock.php
  4. 25 9
      lib/Unit.php
  5. 45 90
      module/scm_product/assets/pc/html/set_seller_goods.html
  6. 1 1
      module/scm_product/database/category.php
  7. 2 2
      module/scm_product/database/info.php
  8. 1 1
      module/scm_product/database/price.php
  9. 1 1
      module/scm_product/index.php
  10. 13 7
      module/scm_product/lib/Info.php
  11. 27 17
      module/scm_product/lib/Manage.php
  12. 2 2
      module/scm_product/lib/Price.php
  13. 6 2
      module/scm_product/lib/Set.php
  14. 3 3
      module/scm_product/lib/Sku.php
  15. 6 0
      module/scm_seller/assets/manage/html/order_goods.html
  16. 251 0
      module/scm_seller/database/buy_order.php
  17. 159 0
      module/scm_seller/database/buy_order_goods.php
  18. 81 11
      module/scm_seller/database/goods.php
  19. 295 0
      module/scm_seller/database/in_order.php
  20. 226 0
      module/scm_seller/database/in_order_goods.php
  21. 106 0
      module/scm_seller/database/in_order_type.php
  22. 102 105
      module/scm_seller/database/info.php
  23. 115 0
      module/scm_seller/database/servicer.php
  24. 282 0
      module/scm_seller/database/shop.php
  25. 115 146
      module/scm_seller/database/shop_goods.php
  26. 245 0
      module/scm_seller/database/shop_goods_list.php
  27. 115 0
      module/scm_seller/database/shop_store.php
  28. 115 0
      module/scm_seller/database/supplier.php
  29. 108 0
      module/scm_seller/lib/Manage.php
  30. 5 0
      module/scm_seller/template/manage/order_goods.php
  31. 341 0
      module/scm_servicer/assets/pc/html/set_servicer.html
  32. 342 0
      module/scm_servicer/assets/pc/html/set_store.html
  33. 1 1
      module/scm_servicer/database/in_order.php
  34. 1 1
      module/scm_servicer/database/in_order_goods.php
  35. 0 10
      module/scm_servicer/database/in_order_type.php
  36. 39 38
      module/scm_servicer/database/info.php
  37. 1 1
      module/scm_servicer/database/out_order_goods.php
  38. 0 10
      module/scm_servicer/database/out_order_type.php
  39. 64 5
      module/scm_servicer/database/store.php
  40. 94 7
      module/scm_servicer/database/store_goods.php
  41. 36 35
      module/scm_servicer/database/store_goods_list.php
  42. 105 0
      module/scm_servicer/database/type.php
  43. 5 1
      module/scm_servicer/lib/Manage.php
  44. 112 0
      module/scm_servicer/lib/Set.php
  45. 117 0
      module/scm_servicer/lib/Set_store.php
  46. 2 2
      module/scm_supplier/assets/pc/html/set_supplier.html
  47. 23 23
      module/scm_supplier/database/info.php
  48. 1 1
      module/scm_supplier/lib/Manage.php
  49. 1 1
      module/scm_supplier/lib/Set.php

+ 221 - 0
lib/Assign.php

@@ -0,0 +1,221 @@
+<?php
+
+namespace Scm\Lib;
+
+use Dever;
+
+class Assign
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    public function get(&$goods, &$order, $shop, $state = false)
+    {
+        if (strstr($order['order_num'], '_')) {
+            $temp = explode('_', $order['order_num']);
+            $order['order_num'] = $temp[0];
+            $order['order_index'] = $temp[1];
+        } else {
+            $order['order_index'] = 0;
+        }
+        # 获取门店分配的仓库和供应商
+        $data = $source = array();
+
+        $source[] = array
+        (
+            'type' => -1,
+            'id' => -1,
+            'name' => '未分配供货商',
+        );
+
+        $this->assign_store($data, $goods, $source, $order, $shop);
+        $this->assign_factory($data, $goods, $source, $order, $shop);
+
+        if ($state) {
+            return array($data, $source);
+        }
+
+        return $data;
+    }
+
+    private function assign_store(&$data, &$goods, &$source, $order, $shop)
+    {
+        $shop_store = Dever::db('shop/store')->select(array('shop_id' => $shop['id']));
+        $store = array();
+        $distance = array();
+
+        # 按照距离排序
+        if ($shop_store) {
+            foreach ($shop_store as $k => $v) {
+                $info = Dever::db('store/info')->find($v['store_id']);
+                if ($info && $info['status'] == 1) {
+                    $distance[] = $info['distance'] = Dever::distance($shop['lng'], $shop['lat'], $info['lng'], $info['lat']);
+                    $store[] = $info;
+                }
+            }
+
+            if ($store) {
+                array_multisort($distance, SORT_ASC, SORT_NUMERIC, $store);
+
+                foreach ($store as $k => $v) {
+                    $store[$k]['type'] = 2;
+                    //$source[] = $store[$k];
+                    if ($goods) {
+                        foreach ($goods as $gk => $gv) {
+                            $where = array();
+                            $where['store_id'] = $v['id'];
+                            $where['goods_id'] = $gv['goods_id'];
+                            $where['sku_id'] = ($gv['sku_id'] && $gv['sku_id'] > 0) ? $gv['sku_id'] : -1;
+                            $sku = Dever::db('store/goods_sku')->getOne($where);
+                            if ($sku) {
+                                $source[$v['id']] = $store[$k];
+                                if ($gv['num'] <= $sku['total']) {
+                                    # 库存符合
+                                    $data['2_' . $v['id']][] = array
+                                    (
+                                        'area' => $shop['area'],
+                                        'order_id' => $order['id'],
+                                        'order_type' => $order['type'],
+                                        'order_num' => $order['order_num'],
+                                        'order_index' => $order['order_index'],
+                                        'type' => 1,
+                                        'type_id' => $shop['id'],
+                                        'source_type' => 2,
+                                        'source_id' => $v['id'],
+                                        'source_name' => $v['name'],
+                                        'order_goods_id' => $gv['id'],
+                                        'goods_id' => $where['goods_id'],
+                                        'sku_id' => $where['sku_id'],
+                                        'price' => $gv['price'],
+                                        'p_price' => $gv['price'],
+                                        'num' => $gv['num'],
+                                    );
+                                    unset($goods[$gk]);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            return $store;
+        }
+        return false;
+    }
+
+    private function assign_factory(&$data, &$goods, &$source, $order, $shop)
+    {
+        $where = array('shop_id' => $shop['id']);
+        $lng = $shop['lng'];
+        $lat = $shop['lat'];
+        $address = array();
+        if (isset($order['parent_type'])) {
+            if ($order['parent_type'] == 2) {
+                # 平台商城
+                $sell_order = Dever::db('shop/sell_order')->find($order['parent_order_id']);
+                if ($sell_order) {
+                    $address = Dever::db('passport/address')->find($sell_order['address_id']);
+                }
+            } elseif ($order['parent_type'] == 3) {
+                # 代理商下单
+                $dh_order = Dever::db('agent/dh_order')->find($order['parent_order_id']);
+                if ($dh_order) {
+                    $address = Dever::db('agent/member_address')->find($dh_order['address_id']);
+                }
+            }
+        } elseif (isset($order['type'])) {
+            if ($order['type'] == 2) {
+                # 平台商城
+                $address = Dever::db('passport/address')->find($order['address_id']);
+            } elseif ($order['type'] == 3) {
+                # 代理商下单
+                $address = Dever::db('agent/member_address')->find($order['address_id']);
+            }
+        }
+        
+
+        $w = array();
+
+        $state = false;
+        if ($goods) {
+            foreach ($goods as $gk => $gv) {
+                if ($gv['goods_id'] == 10000289) {
+                    $state = true;
+                }
+            }
+        }
+        if ($state && $address && $address['province'] && $address['city']) {
+            $area_ship = Dever::db('shop/area_ship')->find(array('area' => $address['province'] . ',' . $address['city']));
+
+            if (!$area_ship) {
+                $area_ship = Dever::db('shop/area_ship')->find(array('area' => $address['province'] . ',-1'));
+            }
+            if ($area_ship) {
+                $w['area_ship'] = $area_ship['area_id'];
+            }
+        }
+
+        $shop_factory = Dever::db('shop/factory')->select($where);
+        $factory = array();
+        $distance = array();
+
+        # 按照距离排序
+        if ($shop_factory && $goods) {
+            foreach ($shop_factory as $k => $v) {
+                $w['id'] = $v['factory_id'];
+                $info = Dever::db('factory/info')->find($w);
+                if ($info && $info['status'] == 1) {
+                    $distance[] = $info['distance'] = Dever::distance($lng, $lat, $info['lng'], $info['lat']);
+                    $factory[] = $info;
+                }
+            }
+
+            if ($factory) {
+                array_multisort($distance, SORT_ASC, SORT_NUMERIC, $factory);
+
+                foreach ($factory as $k => $v) {
+                    $factory[$k]['type'] = 3;
+                    //$source[] = $factory[$k];
+                    if ($goods) {
+                        foreach ($goods as $gk => $gv) {
+                            $where = array();
+                            $where['factory_id'] = $v['id'];
+                            $where['goods_id'] = $gv['goods_id'];
+                            $where['sku_id'] = ($gv['sku_id'] && $gv['sku_id'] > 0) ? $gv['sku_id'] : -1;
+                            $sku = Dever::db('factory/goods_sku')->getOne($where);
+                            if ($sku) {
+                                $source[$v['id']] = $factory[$k];
+                                $data['3_' . $v['id']][] = array
+                                (
+                                    'area' => $shop['area'],
+                                    'order_id' => $order['id'],
+                                    'order_type' => $order['type'],
+                                    'order_num' => $order['order_num'],
+                                    'order_index' => $order['order_index'],
+                                    'type' => 1,
+                                    'type_id' => $shop['id'],
+                                    'source_type' => 3,
+                                    'source_id' => $v['id'],
+                                    'source_name' => $v['name'],
+                                    'source_info_type' => $v['type'],
+                                    'source_info_shopinfo' => $v['shopinfo'],
+                                    'order_goods_id' => $gv['id'],
+                                    'goods_id' => $where['goods_id'],
+                                    'sku_id' => $where['sku_id'],
+                                    'price' => $gv['price'],
+                                    'p_price' => $sku['p_price'],
+                                    'num' => $gv['num'],
+                                );
+                                unset($goods[$gk]);
+                            }
+                        }
+                    }
+                }
+            }
+            return $factory;
+        }
+
+        return false;
+    }
+}

+ 142 - 18
lib/Order.php

@@ -33,6 +33,22 @@ class Order
 
     public function updateOrderNum($id, $name, $data)
     {
+        $servicer_store_id = Dever::param('servicer_store_id', $data);
+        if ($servicer_store_id) {
+            $info = Dever::db('scm_servicer/store')->find($servicer_store_id);
+            if ($info && $info['type'] == 1 && (!$info['area'] || !$info['address'] || !$info['truename'] || !$info['tel'])) {
+                Dever::alert('仓库[' . $info['name'] . ']收货地址未填写');
+            }
+        }
+
+        $seller_shop_id = Dever::param('seller_shop_id', $data);
+        if ($seller_shop_id) {
+            $info = Dever::db('scm_seller/shop')->find($seller_shop_id);
+            if ($info && $info['type'] == 1 && (!$info['area'] || !$info['address'] || !$info['truename'] || !$info['tel'])) {
+                Dever::alert('门店[' . $info['name'] . ']收货地址未填写');
+            }
+        }
+        
         $table = Dever::input('table');
         $prefix = Dever::input('prefix');
         if ($table && $prefix) {
@@ -46,7 +62,6 @@ class Order
     # 生成订单号
     public function getOrderNum($table, $prefix = 'C')
     {
-        $prefix = $prefix . ucfirst(substr($table, 0, 1));
         $where['order_num'] = Dever::order($prefix);
         $state = Dever::db($table)->one($where);
         if (!$state) {
@@ -77,6 +92,7 @@ class Order
         $role = $this->show_role(array
         (
             'seller' => '经销商',
+            'seller_shop' => '门店',
             'servicer' => '配送商',
             'servicer_store' => '仓库',
             'supplier' => '供应商',
@@ -93,7 +109,12 @@ class Order
 
         $this->show_address($order, $role, $result);
 
-        $this->show_goods($order, $order_table, $result);
+        $audit = Dever::input('audit');
+        if ($audit == 1) {
+            $this->show_goods_audit($order, $order_table, $result);
+        } else {
+            $this->show_goods($order, $order_table, $result);
+        }
 
         $head = array
         (
@@ -145,11 +166,18 @@ class Order
     # 显示订单地址
     private function show_address($order, $role, &$result)
     {
-        if (!$order['address'] && isset($role['servicer_store']['address'])) {
-            $order['address'] = $role['servicer_store']['address'];
+        if (!$order['address']) {
+            if (isset($role['servicer_store'])) {
+                $address = $role['servicer_store'];
+            }
+            if (isset($role['seller_shop'])) {
+                $address = $role['seller_shop'];
+            }
+        } else {
+            $address = Dever::json_decode($order['address']);
         }
-        if ($order['address']) {
-            $temp = explode('、', $order['address']);
+        if ($address) {
+            $address['area'] = Dever::load('area/api')->string($address['area']);
             $result['收货信息'] = array
             (
                 'type' => 'info',
@@ -157,9 +185,9 @@ class Order
                 (
                     array
                     (
-                        array('联系人', $temp[1]),
-                        array('联系电话', $temp[2]),
-                        array('收货地址', $temp[0]),
+                        array('联系人', $address['truename']),
+                        array('联系电话', $address['tel']),
+                        array('收货地址', $address['area'] . ',' . $address['address']),
                     ),
                 ),
             );
@@ -171,7 +199,7 @@ class Order
     {
         $data = Dever::db($order_table . '_goods')->select(array('order_id' => $order['id']));
         if ($data) {
-            $table['head'] = array('商品编码', '商品名称', '商品规格', '批次', '单价', '数量', '总价', '状态');
+            $table['head'] = array('商品编码', '商品名称', '批次', '单价', '数量', '总价', '状态');
             $table['body'] = array();
             $total_price = $total_num = 0;
             $status = Dever::db($order_table . '_goods')->config['status'];
@@ -192,21 +220,24 @@ class Order
                     }
                 }
 
-                $sdate = isset($v['sdate']) && $v['sdate'] ? '[' . date('Y-m-d', $v['sdate']) . '生产]' : '';
                 $cash = Dever::number($v['cash'] * $v['num']);
 
                 $detail = array
                 (
                     $goods_info['code'],
-                    $goods_info['name'],
-                    $goods_info['spec_name'],
-                    $v['batch'] . $sdate,
-                    $v['cash'],
-                    $v['num'] . $goods_info['unit'],
-                    $cash,
-                    $status_name,
+                    $goods_info['aname'],
                 );
 
+                if (isset($v['batch'])) {
+                    $detail[] = $v['batch'] . (isset($v['sdate']) && $v['sdate'] ? '[' . date('Y-m-d', $v['sdate']) . '生产]' : '');
+                } else {
+                    unset($table['head'][3]);
+                }
+                $detail[] = $v['cash'];
+                $detail[] = $v['num'] . $goods_info['unit'];
+                $detail[] = $cash;
+                $detail[] = $status_name;
+
                 if ($goods_info['goods']) {
                     $detail['goods'] = $goods_info['goods'];
                 }
@@ -242,4 +273,97 @@ class Order
         }
         return $button;
     }
+
+    private function show_goods_audit($order, $order_table, &$result)
+    {
+        $order['type'] = 1;
+
+        $data = Dever::db($order_table . '_goods')->select(array('order_id' => $order['id']));
+
+        $shop = Dever::db('shop/info')->find($order['type_id']);
+
+        list($assign, $source) = Dever::load('scm/lib/assign')->get($goods, $info, $shop, true);
+
+        if ($info) {
+
+            $head = array('商品编码', '商品名称', '批次', '单价', '数量', '总价', '供货商');
+            $body = array();
+            $i = 0;
+            if ($data) {
+                foreach ($assign as $k => $v) {
+                    foreach ($v as $v1) {
+                        $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                        if (isset($goods_info['sku'])) {
+                            $sku = '[' . $goods_info['sku']['string'] . ']';
+                        } else {
+                            $sku = '';
+                        }
+                        $d = array
+                        (
+                            $i+1,
+                            $goods_info['code'],
+                            $goods_info['name'] . $sku,
+                            $this->getSelect($source, $v1['source_id'], $v1['order_goods_id']),
+                            $v1['num'],
+                            $goods_info['unit'],
+                            $v1['p_price'] * $v1['num'],
+                        );
+
+                        $body[] = $d;
+
+                        $i++;
+                    }
+                }
+            }
+            
+            if ($goods) {
+                foreach ($goods as $k => $v) {
+                    $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
+                    if (isset($goods_info['sku'])) {
+                        $sku = '[' . $goods_info['sku']['string'] . ']';
+                    } else {
+                        $sku = '';
+                    }
+                    $d = array
+                    (
+                        $i+1,
+                        $goods_info['code'],
+                        $goods_info['name'] . $sku,
+                        $this->getSelect($source, false, $v['id']),
+                        $v['num'],
+                        $goods_info['unit'],
+                        $v['p_price'] * $v['num'],
+                    );
+
+                    $body[] = $d;
+
+                    $i++;
+                }
+            }
+
+            $btn = array();
+            $btn[] = array(
+                'type' => 'click',
+                'content' => 'setAudit()',
+                'name' => '全部调整<script>function setAudit(){layer.confirm(\'确定进行此项操作吗?\', function(){var audit = $(\'.audit_set\').val();$(\'.audit\').each(function(){$(this).val(audit);layui.form.render();layer.closeAll()})})}</script>'
+            );
+            $result['商品拆单'] = array
+            (
+                'type' => 'table',
+                'head' => array('name' => '供货商:' . $this->getSelect($source, false, false), 'btn' => $btn),
+                'content' => array
+                (
+                    'head' => $head,
+                    'body' => $body,
+                )
+            );
+
+            $url = Dever::url('lib/buy.audit_set_commit?json=1&order_id=' . $info['id'], 'mshop');
+            $result['审核结果'] = array
+            (
+                'type' => 'html',
+                'content' => '<script>function saveAudit(){var goods = [];var audit = 1; var audit_text = $(".update_audit_text").val();$(".update_audit").each(function(){if ($(this).get(0).checked){audit = $(this).val()}});$(\'.audit\').each(function(){var v = $(this).val();var id = $(this).attr("id");goods.push(v + "_" + id);});layer.confirm(\'确定进行此项操作吗?\', function(){layui.form.render();var send = {};send.goods = goods.join(",");send.audit = audit;send.audit_text = audit_text;console.info(send);$.post("'.$url.'", send, function(t){t = JSON.parse(t);showYes(t)})})}</script><style>.layui-form-radio{padding-right: 0px;margin: 0px 0px 0 0;margin-left:40px}</style><div class="layui-form-item  show_input"><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">审核状态</label><div style="display:inline" class="am-btn-group"><input update_type="checked" class="checkbox-checkall-0_update_audit update_audit update_value validate[required]" type="radio" name="update_audit[]" value="2" checked="" show_id="audit" autocomplete="off" id="form-validation-field-1"> 审核通过 &nbsp;&nbsp;<input update_type="checked" class="autoload checkbox-checkall-0_update_audit update_audit update_value validate[required]" type="radio" name="update_audit[]" value="3" autocomplete="off" id="form-validation-field-0"> 审核未通过 &nbsp;&nbsp;</div></div></div></div><div class="layui-form-item" style="display: block;"><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">审核备注</label></div><div><textarea style="height:100px;" update_type="value" class="update_value update_audit_text form-control layui-input validate[required]" name="update_desc"></textarea></div></div></div> <div style="text-align:left" class="layui-layer-btn layui-layer-btn-"><a class="layui-btn layui-btn-primary" onclick="saveAudit()">保存</a><a class="layui-layer-btn1" style="display:none">取消</a></div>',
+            );
+        }
+    }
 }

+ 29 - 16
lib/Stock.php

@@ -20,9 +20,9 @@ class Stock
 		$table = Dever::input('table');
 		$col = Dever::input('col');
 		list($goods_id, $sku_id) = explode('-', $goods);
-		$where[$col] = Dever::input('update_' . $col);
-
-		$info = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit_id, false, false, $table, $where);
+		
+		Dever::setInput($col, Dever::input('update_' . $col));
+		$info = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit_id);
 		$error = false;
 		if ($info) {
 			$num = Dever::param('num', $data);
@@ -88,11 +88,6 @@ class Stock
     		$order_goods = Dever::db($table . '_goods')->select(array('order_id' => $info['id'], 'status' => 1));
 			if ($order_goods) {
 				foreach ($order_goods as $k => $v) {
-					$update = array('goods_id' => $v['goods_id'], $col => $info[$col], 'clear' => true);
-					$goods = Dever::db($stock)->find($update);
-					if (!$goods) {
-						Dever::db($stock)->insert($update);
-					}
 
 					$result = Dever::load('scm/lib/unit')->convertBase($v['goods_id'], $v['sku_id'], $v['unit_id'], $v['num'], $v['cash']);
 					if ($result) {
@@ -104,6 +99,22 @@ class Stock
     					Dever::alert('商品不存在');
 					}
 
+					$update = array($col => $info[$col], 'clear' => true);
+					$where = $update;
+					$where['goods_id'] = $v['goods_id'];
+					$where['sku_id'] = $v['sku_id'];
+					$where['unit_id'] = $v['unit_id'];
+					$goods = Dever::db($stock)->find($where);
+					if (!$goods) {
+						$update['store_goods_id'] = Dever::db($stock)->insert($where);
+					} else {
+						$update['store_goods_id'] = $goods['id'];
+					}
+
+					if (!$update['store_goods_id']) {
+						continue;
+					}
+
 					$temp = explode('/', $stock);
 					$list_table = $stock . '_list';
 					$goods_list_id = $temp[1] . '_list_id';
@@ -113,8 +124,6 @@ class Stock
 						if (!$v['batch']) {
 							$v['batch'] = date('Ymd');
 						}
-						$update['sku_id'] = $v['sku_id'];
-						$update['unit_id'] = $v['unit_id'];
 						$update['batch'] = $v['batch'];
 						$update['cash'] = $v['cash'];
 						if ($v['sdate']) {
@@ -122,8 +131,6 @@ class Stock
 						}
 						$goods = Dever::db($list_table)->find($update);
 						if (!$goods) {
-							$update['cash'] = $v['cash'];
-							$update['unit_id'] = $v['unit_id'];
 							$id = Dever::db($list_table)->insert($update);
 							$where['where_id'] = $id;
 						} else {
@@ -132,12 +139,10 @@ class Stock
 
 						Dever::db($table . '_goods')->update(array('where_id' => $v['id'], $goods_list_id => $where['where_id']));
 
-						$where[$type . '_num'] = $v['num'];
-						$method = $type . 'Update';
-						Dever::db($list_table)->$method($where);
+						$where['in_num'] = $v['num'];
+						Dever::db($list_table)->inUpdate($where);
 					} elseif ($type == 'out') {
 						# 出库
-						$update['sku_id'] = $v['sku_id'];
 						# **** 出库形式,现在按照先入先出,之后这里可以根据商品,改成加权平均出库
 						$goods = Dever::db($list_table)->getList($update);
 						if ($goods) {
@@ -155,6 +160,14 @@ class Stock
 						}
 					}
 
+					# 同步
+					$list_info = Dever::db($list_table)->getOneByStore(array('store_goods_id' => $update['store_goods_id'], 'clear' => true));
+					if ($list_info) {
+						foreach ($list_info as $k1 => $v1) {
+							Dever::db($stock)->update(array('where_id' => $update['store_goods_id'], 'in_num' => $v1['in_num'], 'out_num' => $v1['out_num'], 'cash' => $v1['cash']));
+						}
+					}
+
 					//Dever::db($table . '_goods')->update(array('where_id' => $v['id'], 'status' => 2));
 				}
 			}

+ 25 - 9
lib/Unit.php

@@ -77,16 +77,23 @@ class Unit
     }
 
     # 获取库中的基础单位的总价和总数
-    public function getData($goods_id, $sku_id, $unit_id = false, $supplier_id = false, $cash_col = false, $table = false, $where = array())
+    public function getData($goods_id, $sku_id, $unit_id = false, $cash_col = false)
     {
         $where['goods_id'] = $goods_id;
         $where['sku_id'] = $sku_id;
 
+        # 获取当前库存
         # 仓库
         $servicer_store_id = Dever::input('servicer_store_id');
         if ($servicer_store_id) {
             $where['servicer_store_id'] = $servicer_store_id;
-            $table = 'scm_servicer/store_goods_list';
+            $table = 'scm_servicer/store_goods';
+        }
+        # 门店
+        $seller_shop_id = Dever::input('seller_shop_id');
+        if ($seller_shop_id) {
+            $where['seller_shop_id'] = $seller_shop_id;
+            $table = 'scm_seller/shop_goods';
         }
 
         $result = array();
@@ -96,7 +103,7 @@ class Unit
             $list = Dever::db($table)->getUnit($where);
             if ($list) {
                 foreach ($list as $k => $v) {
-                    $base = $this->convertBase($goods_id, $sku_id, $v['unit_id'], $v['total'], $v['cash'], $supplier_id);
+                    $base = $this->convertBase($goods_id, $sku_id, $v['unit_id'], $v['total'], $v['cash']);
                     if ($base) {
                         $result['num'] += $base['num'];
                         $result['cash'] += $base['cash'];
@@ -109,7 +116,7 @@ class Unit
             if ($cash_col) {
                 $result['cash'] = $cash_col;
             }
-            $unit = $this->convertUnit($goods_id, $sku_id, $unit_id, $result['num'], $result['cash'], $supplier_id);
+            $unit = $this->convertUnit($goods_id, $sku_id, $unit_id, $result['num'], $result['cash']);
             if ($unit) {
                 $result['num'] = $unit['num'];
                 $result['cash'] = $unit['cash'];
@@ -123,9 +130,9 @@ class Unit
     }
 
     # 将单位转换成基础单位,并获取基础价格和基础数量 unit_id 当前单位,num当前单位数量, cash当前单位价格
-    public function convertBase($goods_id, $sku_id, $unit_id, $num, $cash, $supplier_id = false)
+    public function convertBase($goods_id, $sku_id, $unit_id, $num, $cash)
     {
-        $result = $this->getInfo($goods_id, $sku_id, $unit_id, $num, $cash, $supplier_id);
+        $result = $this->getInfo($goods_id, $sku_id, $unit_id, $num, $cash);
         if ($result) {
             # 基础单位和当前单位不同
             if ($result['unit']) {
@@ -142,9 +149,9 @@ class Unit
     }
 
     # 获取当前单位对应基础单位的价格和数量 unit_id 当前单位,base_num基础单位数量, base_cash基础单位价格
-    public function convertUnit($goods_id, $sku_id, $unit_id, $base_num, $base_cash, $supplier_id = false)
+    public function convertUnit($goods_id, $sku_id, $unit_id, $base_num, $base_cash)
     {
-        $result = $this->getInfo($goods_id, $sku_id, $unit_id, $base_num, $base_cash, $supplier_id);
+        $result = $this->getInfo($goods_id, $sku_id, $unit_id, $base_num, $base_cash);
         if ($result) {
             # 基础单位和当前单位不同
             if ($result['unit']) {
@@ -162,18 +169,27 @@ class Unit
         return $result;
     }
 
-    private function getInfo($goods_id, $sku_id, $unit_id, $num, $cash, $supplier_id = false)
+    private function getInfo($goods_id, $sku_id, $unit_id, $num, $cash)
     {
         $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
         $result = array();
         if ($goods_info) {
             # 获取供应商供货价
+            $supplier_id = Dever::input('supplier_id');
             if ($supplier_id) {
                 $where['supplier_id'] = $supplier_id;
                 $where['goods_id'] = $goods_id;
                 $where['sku_id'] = $sku_id;
                 $sku = Dever::db('scm_supplier/goods')->getOne($where);
             }
+            # 获取经销商采购价
+            $seller_id = Dever::input('seller_id');
+            if ($seller_id) {
+                $seller = Dever::db('scm_seller/info')->find($seller_id);
+                if ($seller && $seller['price_id'] > 0) {
+                    list($sku['price'], $sku['buy_price']) = Dever::load('scm_product/lib/price')->get($seller['price_id'], $goods_id, $sku_id, $goods_info['price'], $goods_info['buy_price']);
+                }
+            }
             if (!is_numeric($cash)) {
                 $cash = isset($sku[$cash]) && $sku[$cash] ? $sku[$cash] : $goods_info[$cash];
             }

+ 45 - 90
module/scm_product/assets/pc/html/set_seller_goods.html

@@ -37,17 +37,6 @@
         <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> 
@@ -59,10 +48,10 @@
                             <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:'number', edit: 'text'}">采购起订数</th>
                                 <th lay-data="{field:'operation'}">操作</th>
                             </tr>
@@ -73,7 +62,7 @@
                     </table>
                 </div>
                 <div class="total ft16">
-                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】
+                    合计:【<span> 商品总数:<i class="totalNum">0</i> </span>】
                 </div>
                 <div class="towbtn">
                     <input type="button" id="settlement" value="确认设置">
@@ -126,13 +115,14 @@
         $("#settlement").click(function(){
             var url = '<{$submit}>';
             var id = '<{$id}>';
-            var role = '<{$role}>';
+            var project = '<{$project}>';
+            var table = '<{$table}>';
 
             layui.layer.confirm('确定进行此项设置吗?', function() {
                 var goods_string = JSON.stringify(goods);
 
                 var data = {};
-                data = {id:id, role:role, goods:goods_string};
+                data = {id:id, project:project, table:table, goods:goods_string};
                 $.post(url, data, function(t) {
                     t = JSON.parse(t);
                     if (t.status == 1) {
@@ -151,25 +141,25 @@
             });
         })
 
-        $("#goods").on("keyup", ".goods_num", function() {
-            var num = parseFloat($(this).val());
-            if (num < 0) {
-                num = 0;
-                $(this).val(0);
+        $("#goods").on("keyup", ".goods_sell_min", function() {
+            var min = parseFloat($(this).val());
+            if (min < 0) {
+                min = 1;
+                $(this).val(1);
             }
             var id = $(this).parent().attr('value');
-            goods[id].num = num;
+            goods[id].sell_min = min;
             setTotal();
         });
 
-        $("#goods").on("keyup", ".goods_min", function() {
+        $("#goods").on("keyup", ".goods_buy_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;
+            goods[id].buy_min = min;
             setTotal();
         });
     })
@@ -310,7 +300,6 @@
             if (goods[node.id]) {
                 goods[node.id].del = 2;
                 goods[node.id].num = 0;
-                goods[node.id].total = 0;
                 get(node.id).remove();
             }
         }
@@ -324,14 +313,14 @@
                 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].sell_min = goods[key].sell_min ? parseFloat(goods[key].sell_min) : 1;
+                goods[key].buy_min = goods[key].buy_min ? parseFloat(goods[key].buy_min) : 1;
                 goods[key].num = 0;
                 goods[key].del = 1;
                 create(node);
                 setTotal();
             } else if(node.type < 4) {
-                add(key);
+                //add(key);
             }
         }
     }
@@ -348,28 +337,23 @@
             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) {
+            if (commission == 'no') {
                 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);
+                if (commission_string.indexOf('%') > -1) {
+                    commission_price = commission_string.replace('%', '');
+                    commission_price = parseFloat(commission_price);
+                    commission_price = (commission_price/100) * parseFloat(node.price);
                 } else {
-                    commission_price = parseFloat(node.commission);
+                    commission_price = parseFloat(nodcommission_string);
                 }
 
                 if (commission) {
@@ -390,13 +374,11 @@
 
             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>';
+            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="decSellMin(\''+node.id+'\')">-</span><input type="text" value="'+node.sell_min+'" class="goods_sell_min"><span class="jia" onclick="addSellMin(\''+node.id+'\')">+</span></div></td>';
+
+            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="decBuyMin(\''+node.id+'\')">-</span><input type="text" value="'+node.buy_min+'" class="goods_buy_min"><span class="jia" onclick="addBuyMin(\''+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 += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
                                   
             addtr += '</tr>';
             $("#goods").append(addtr);
@@ -405,81 +387,54 @@
         }
     }
 
-    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)
+    function addSellMin(id)
     {
-        goods[id].num += 1;
-        get(id).find('.goods_num').val(goods[id].num);
+        goods[id].sell_min += 1;
+        get(id).find('.goods_sell_min').val(goods[id].sell_min);
         setTotal();
     }
     
-    function dec(id)
+    function decSellMin(id)
     {
-        goods[id].num -= 1;
-        if (goods[id].num < 1) {
-            goods[id].num = 0;
+        goods[id].sell_min -= 1;
+        if (goods[id].sell_min < 1) {
+            goods[id].sell_min = 0;
         }
-
-        get(id).find('.goods_num').val(goods[id].num);
+        get(id).find('.goods_sell_min').val(goods[id].sell_min);
         setTotal();
     }
 
-    function addMin(id)
+    function addBuyMin(id)
     {
-        goods[id].min += 1;
-        get(id).find('.goods_min').val(goods[id].min);
+        goods[id].buy_min += 1;
+        get(id).find('.goods_buy_min').val(goods[id].buy_min);
         setTotal();
     }
     
-    function decMin(id)
+    function decBuyMin(id)
     {
-        goods[id].min -= 1;
-        if (goods[id].min < 1) {
-            goods[id].min = 0;
+        goods[id].buy_min -= 1;
+        if (goods[id].buy_min < 1) {
+            goods[id].buy_min = 0;
         }
-
-        get(id).find('.goods_min').val(goods[id].min);
+        get(id).find('.goods_buy_min').val(goods[id].buy_min);
         setTotal();
     }
 
     function del(id)
     {
-        //if (confirm('确定删除吗?')) {
+        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;
-        });
+        $(".totalNum").html(Object.keys(goods).length);
     }
 </script>
 </body>

+ 1 - 1
module/scm_product/database/category.php

@@ -11,7 +11,7 @@ return array
 	# 表名
 	'name' => 'category',
 	# 显示给用户看的名称
-	'lang' => '属性分类',
+	'lang' => '商品属性分类',
 	# 是否显示在后台菜单
 	'order' => 300,
 

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

@@ -81,8 +81,8 @@ $config = array
 	# 表名
 	'name' => 'info',
 	# 显示给用户看的名称
-	'lang' => '商品资料',
-	'order' => 500,
+	'lang' => '平台商品管理',
+	'order' => 1000,
 	'auto' => 10000000,
 	'set' => array
 	(

+ 1 - 1
module/scm_product/database/price.php

@@ -34,7 +34,7 @@ return array
 	# 表名
 	'name' => 'price',
 	# 显示给用户看的名称
-	'lang' => '价格模板',
+	'lang' => '价格模板设置',
 	'info' => '在商品中设置的价格是默认价格,如果一个SKU想设置不同的价格,则可以通过价格模板设置',
 	# 是否显示在后台菜单
 	'order' => 100,

+ 1 - 1
module/scm_product/index.php

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

+ 13 - 7
module/scm_product/lib/Info.php

@@ -119,7 +119,7 @@ class Info
                     $result[$i]['total'] = isset($v['total']) ? $v['total'] : 0;
 
                     if ($price_id > 0 && $sku[0]['key'] == -1) {
-                        list($result[$i]['price'], $result[$i]['buy_price']) = Dever::load('scm_product/lib/price')->get($price_id, $v, $sku[0], $result[$i]['price'], $result[$i]['buy_price']);
+                        list($result[$i]['price'], $result[$i]['buy_price']) = Dever::load('scm_product/lib/price')->get($price_id, $v['id'], $sku[0]['id'], $result[$i]['price'], $result[$i]['buy_price']);
                     }
                     
                     if ($other) {
@@ -135,8 +135,11 @@ class Info
                         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['sell_min']) && $other['sell_min']) {
+                            $result[$i]['sell_min'] = $other['sell_min'];
+                        }
+                        if (isset($other['buy_min']) && $other['buy_min']) {
+                            $result[$i]['buy_min'] = $other['buy_min'];
                         }
                         if (isset($other['source_id']) && $other['source_id']) {
                             $result[$i]['source_id'] = $other['source_id'];
@@ -219,7 +222,7 @@ class Info
                                 $children['set'] = $set;
                             }
                             if ($price_id > 0) {
-                                list($children['price'], $children['buy_price']) = Dever::load('scm_product/lib/price')->get($price_id, $v, $v1, $children['price'], $children['buy_price']);
+                                list($children['price'], $children['buy_price']) = Dever::load('scm_product/lib/price')->get($price_id, $v['id'], $v1['id'], $children['price'], $children['buy_price']);
                             }
                             if ($other_sku) {
                                 if (isset($other_sku['commission']) && $other_sku['commission']) {
@@ -234,8 +237,11 @@ class Info
                                 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['sell_min']) && $other_sku['sell_min']) {
+                                    $children['sell_min'] = $other_sku['sell_min'];
+                                }
+                                if (isset($other_sku['buy_min']) && $other_sku['buy_min']) {
+                                    $children['buy_min'] = $other_sku['buy_min'];
                                 }
                                 if (isset($other_sku['source_id']) && $other_sku['source_id']) {
                                     $children['source_id'] = $other_sku['source_id'];
@@ -283,7 +289,7 @@ class Info
                     if ($seller_id) {
                         $seller = Dever::db('scm_role/seller')->find($seller_id);
                         if ($seller) {
-                            list($sku['price'], $sku['buy_price']) = Dever::load('scm_product/lib/price')->get($seller['price_id'], $info, $sku, $sku['price'], $sku['buy_price']);
+                            list($sku['price'], $sku['buy_price']) = Dever::load('scm_product/lib/price')->get($seller['price_id'], $info['id'], $sku['id'], $sku['price'], $sku['buy_price']);
                         }
                     }
                     $info['price'] = $sku['price'];

+ 27 - 17
module/scm_product/lib/Manage.php

@@ -101,11 +101,9 @@ class Manage
         $cate = '';
         $supplier_id = Dever::input('supplier_id');
         if ($supplier_id) {
-            $supplier_goods = Dever::db('scm_supplier/goods')->one(array('supplier_id' => $supplier_id));
-            if ($supplier_goods) {
-                $where['supplier_id'] = $supplier_id;
-                $data = Dever::search('scm_supplier/goods_sku', $where);
-            } else {
+            $where['supplier_id'] = $supplier_id;
+            $data = Dever::search('scm_supplier/goods', $where);
+            if (!$data) {
                 $supplier = Dever::db('scm_supplier/info')->find($supplier_id);
                 if ($supplier && $supplier['category']) {
                     $cate = $supplier['category'];
@@ -113,17 +111,23 @@ class Manage
             }
         }
 
+        $seller_id = Dever::input('seller_id');
+        if ($seller_id) {
+            $where['seller_id'] = $seller_id;
+            $data = Dever::search('scm_seller/goods', $where);
+            if (!$data) {
+                $seller = Dever::db('scm_seller/info')->find($seller_id);
+                if ($seller && $seller['category']) {
+                    $cate = $seller['category'];
+                }
+            }
+        }
+
         $service_id = Dever::input('service_id');
         $servicer_store_id = Dever::input('servicer_store_id');
         if ($servicer_store_id) {
-            $store_goods = Dever::db('scm_servicer/store_goods')->one(array('servicer_store_id' => $servicer_store_id));
-            if ($store_goods) {
-                $where['servicer_store_id'] = $servicer_store_id;
-                $data = Dever::search('scm_servicer/store_goods_list', $where);
-            } else {
-                # 没有库存
-                return array();
-            }
+            $where['servicer_store_id'] = $servicer_store_id;
+            $data = Dever::search('scm_servicer/store_goods', $where);
         }
 
         if (!$data) {
@@ -194,7 +198,12 @@ class Manage
                 $status_name = Dever::status($status, $v['status']);
                 $unit = Dever::db('scm/unit')->one($v['unit_id']);
                 $result['body'][$k][] = $goods_info['aname'];
-                $result['body'][$k][] = $v['batch'];
+                if (isset($v['batch'])) {
+                    $result['body'][$k][] = $v['batch'];
+                } else {
+                    unset($result['head'][1]);
+                }
+                
                 $result['body'][$k][] = $v['cash'];
                 $result['body'][$k][] = $v['num'] . $unit['name'];
                 $result['body'][$k][] = $status_name;
@@ -247,10 +256,11 @@ class Manage
             $string = '';
             $table = Dever::input('table');
             $unit_id = false;
-            if ($table == 'in_order') {
+            if ($table != 'out_order') {
+                # 出库不需要
                 $unit_id = -1;
             }
-            $data = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit_id, Dever::input('supplier_id'), Dever::input('cash_col'));
+            $data = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit_id, Dever::input('cash_col'));
             if ($data) {
                 $result['cash'] = $data['cash'];
                 $result['goods_id'] = $data['num'] . $goods_info['unit'] . $string;
@@ -285,7 +295,7 @@ class Manage
         $temp = explode('-', $goods);
         $goods_id = $temp[0];
         $sku_id = $temp[1];
-        $data = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit, Dever::input('supplier_id'), Dever::input('cash_col'));
+        $data = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit, Dever::input('cash_col'));
         if ($data && $data['num'] > 0) {
             $unit = Dever::db('scm/unit')->one($unit);
             $data['goods_id'] = $data['num'] . $unit['name'];

+ 2 - 2
module/scm_product/lib/Price.php

@@ -12,7 +12,7 @@ class Price
     }
 
     # 获取价格模板信息
-    public function get($price_id, $product, $sku, $price, $buy_price)
+    public function get($price_id, $goods_id, $sku_id, $price, $buy_price)
     {
         # 暂时未增加临期价格
 
@@ -34,7 +34,7 @@ class Price
                         $get = true;
                     }
                     if ($get) {
-                        $info = Dever::db('scm_product/price_rule_sku')->find(array('price_rule_id' => $v['id'], 'goods_id' => $product['id'], 'sku_id' => $sku['id']));
+                        $info = Dever::db('scm_product/price_rule_sku')->find(array('price_rule_id' => $v['id'], 'goods_id' => $goods_id, 'sku_id' => $sku_id));
                         if ($info) {
                             $price = Dever::per($price, $info['price']);
                             $buy_price = Dever::per($buy_price, $info['buy_price']);

+ 6 - 2
module/scm_product/lib/Set.php

@@ -72,6 +72,7 @@ class Set
         $where['set_state'] = 2;
         Dever::db($table_goods)->updates($where);
 
+
         foreach ($goods as $k => $v) {
             $temp = explode('-', $k);
             $goods_id = $temp[0];
@@ -97,8 +98,11 @@ class Set
                 $goods_info = Dever::db('scm_product/info')->one($goods_id);
                 $info = Dever::db($table_goods)->one($w);
 
-                if (isset($v['min'])) {
-                	$w['min'] = $v['min'];
+                if (isset($v['sell_min'])) {
+                	$w['sell_min'] = $v['sell_min'];
+                }
+                if (isset($v['buy_min'])) {
+                    $w['buy_min'] = $v['buy_min'];
                 }
                 if (isset($v['cost_price'])) {
                 	$w['cost_price'] = $v['cost_price'];

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

@@ -30,8 +30,8 @@ class Sku
                 foreach ($sku as $k => $v) {
                     $copy = $info;
                     $copy['id'] .= '-' . $v['id'];
-                    if (isset($info['supplier_id']) && isset($info['cost_price'])) {
-                        $copy['id'] .= '-' . $info['cost_price'];
+                    if (isset($info['servicer_store_id']) && $info['servicer_store_id']) {
+                        $copy['id'] .= '-' . $info['id'];
                     }
 
                     $key = str_replace('-', ',', $v['key']);
@@ -72,7 +72,7 @@ class Sku
             foreach ($sku as $k => $v) {
                 unset($sku[$k]['key']);
                 if ($seller_id && $seller) {
-                    list($sku[$k]['price'], $sku[$k]['buy_price']) = Dever::load('scm_product/lib/price')->get($seller['price_id'], array('id' => $info_id), $v, $sku[$k]['price'], $sku[$k]['buy_price']);
+                    list($sku[$k]['price'], $sku[$k]['buy_price']) = Dever::load('scm_product/lib/price')->get($seller['price_id'], $info_id, $v['id'], $sku[$k]['price'], $sku[$k]['buy_price']);
                 }
                 
                 if ($type == 1) {

+ 6 - 0
module/scm_seller/assets/manage/html/order_goods.html

@@ -0,0 +1,6 @@
+
+<form class="layui-form form10" action="" target="f10" method="post">
+<iframe id="f10" name="f10" style="display:none;"></iframe>
+<div class="layui-form-item" id="show">
+</div>
+</form>

+ 251 - 0
module/scm_seller/database/buy_order.php

@@ -0,0 +1,251 @@
+<?php
+
+$status = array
+(
+	1 => array('name' => '待支付', 'style' => 'font-weight:bold;color:#F8046E'),
+    2 => array('name' => '待审核', 'style' => 'font-weight:bold;color:#436EEE'),
+    3 => array('name' => '待处理', 'style' => 'font-weight:bold;color:#003366'),
+    4 => array('name' => '待确认', 'style' => 'font-weight:bold;color:#003366'),
+    5 => array('name' => '已完成', 'style' => 'font-weight:bold;color:#0978F8'),
+    6 => array('name' => '已完成(有退款)', 'style' => 'font-weight:bold;color:#0978F8'),
+    7 => array('name' => '已取消', 'style' => 'font-weight:bold;color:#993333'),
+    8 => array('name' => '已退款', 'style' => 'font-weight:bold;color:#993333'),
+    11 => array('name' => '已过期', 'style' => 'font-weight:bold;color:#993333'),
+);
+
+$audit = array
+(
+    1 => '待审核',
+    2 => '审核通过',
+    3 => '审核未通过',
+);
+
+$shop = array();
+$seller_id = Dever::input('search_option_seller_id');
+if ($seller_id) {
+	$shop = function() use($seller_id) {
+		return Dever::db('scm_seller/shop')->state(array('seller_id' => $seller_id, 'status' => 1));
+	};
+}
+
+$seller = function() {
+    return Dever::db('scm_seller/info')->state();
+};
+
+$col = Dever::input('col');
+
+return array
+(
+    # 表名
+    'name' => 'buy_order',
+    # 显示给用户看的名称
+    'lang' => '采购单查询',
+    'order' => 20,
+    'set' => array
+    (
+    	'status' => $status,
+        'audit' => $audit,
+    ),
+    'end' => array
+    (
+        'insert' => 'scm/lib/order.updateOrderNum?table=scm_seller/buy_order&prefix=BU',
+    ),
+
+    # 数据结构
+    '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_seller/lib/manage.info", "buy", {id})',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '经销商',
+            'default'   => '',
+            'desc'      => '经销商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'searchs'    => array
+            (
+                'api' => 'scm_role/seller-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'search'    => 'select',
+            'option'    => $seller,
+            'value'     => $seller_id,
+            //'list'      => 'Dever::load("scm_seller/info-one#name", {seller_id})',
+        ),
+
+        'seller_shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '门店',
+            'default'   => '',
+            'desc'      => '门店',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $shop,
+            //'list'      => 'Dever::load("scm_seller/shop-one#name", {servicer_shop_id})',
+        ),
+
+        'relate_order_num'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '关联单据号',
+            'default'   => '',
+            'desc'      => '关联单据号',
+            'match'     => 'option',
+            //'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单备注',
+            'default'   => '',
+            'desc'      => '订单备注',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'address'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '收货信息',
+            'default'   => '',
+            'desc'      => '收货信息',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+            //'search'    => 'fulltext',
+            //'list'      => true,
+        ),
+
+        'scm_seller-buy_order_goods'=> array
+		(
+			'name' 		=> '商品设置',
+			'default' 	=> '',
+			'desc' 		=> '商品设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'order_id'),
+			'update'	=> array(1),
+			# 1纵向展示 2横向展示
+			'update_type' => 2,
+            'list_name' => '商品信息',
+			'list'		=> 'Dever::load("scm_product/lib/manage.getGoods", {id}, "scm_seller/buy_order_goods")',
+		),
+
+        'audit'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '审核状态',
+            'default'   => '2',
+            'desc'      => '审核状态',
+            'match'     => 'is_numeric',
+            'option'    => $audit,
+            'update'    => $col ? 'radio' : false,
+        ),
+
+        'audit_desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '审核备注',
+            'default'   => '',
+            'desc'      => '审核备注',
+            'match'     => 'option',
+            'update'    => $col ? 'textarea' : false,
+        ),
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '审核人',
+            //'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '2',
+            'desc'      => '订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            //'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
+    (
+        # 后台提交时,检测该值是否为空,多个用逗号隔开
+        'update_check' => 'scm_seller-buy_order_goods',
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        //'excel' => $excel,
+        //'mul' => $mul,
+
+        'list_button' => array
+        (
+            'list' => array('查看详情', '"buy_order_goods&type=buy&page_type=1&order_id={id}"'),
+
+            'list1' => array('审核', '"buy_order_goods&type=buy&page_type=1&order_id={id}&audit=1"', '{status} == 2'),
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 159 - 0
module/scm_seller/database/buy_order_goods.php

@@ -0,0 +1,159 @@
+<?php
+
+$status = array
+(
+    1 => '待审',
+    2 => '已审核',
+    3 => '未通过',
+);
+
+return array
+(
+    # 表名
+    'name' => 'buy_order_goods',
+    # 显示给用户看的名称
+    'lang' => '订单商品表',
+    'menu' => false,
+    'status' => $status,
+    'end' => array
+    (
+        'insert' => 'scm/lib/order.updateGoods?table=scm_seller/buy_order_goods',
+        'update' => 'scm/lib/order.updateGoods?table=scm_seller/buy_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-2000',
+            'name'      => '商品',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'option',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.searchProduct?{seller_id}',
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showInfo?cash_col=buy_price', 'scm_product'), 'col' => 'seller_id,seller_shop_id')),
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '库存',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'is_numeric',
+            'update'    => 'show',
+            'value'     => '暂无',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
+            'match'     => 'is_numeric',
+        ),
+
+        'unit_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '单位',
+            'default'   => '',
+            'desc'      => '单位',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => array(0 => '请先选择商品'),
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showPriceByUnit?cash_col=buy_price', 'scm_product'), 'col' => 'seller_id,seller_shop_id,goods')),
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '单价',
+            'default'   => '',
+            'desc'      => '单价',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '数量',
+            'default'   => '1',
+            'desc'      => '数量',
+            'match'     => 'option',
+            '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,
+        'page_list' => 'order_goods',
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 81 - 11
module/scm_seller/database/goods.php

@@ -1,11 +1,11 @@
 <?php
-
+$status = Dever::config('base')->status;
 return array
 (
     # 表名
     'name' => 'goods',
     # 显示给用户看的名称
-    'lang' => '销商商品列表',
+    'lang' => '销商商品列表',
     'order' => 10,
     'menu'  => false,
 
@@ -36,9 +36,9 @@ return array
         'seller_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '所属销商',
+            'name'      => '所属销商',
             'default'   => '',
-            'desc'      => '所属销商',
+            'desc'      => '所属销商',
             'match'     => 'is_numeric',
             'update'    => 'hidden',
             'search'    => 'hidden',
@@ -58,6 +58,37 @@ return array
             'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
         ),
 
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'sell_min'       => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '销售起订数',
+            'default'   => '1',
+            'desc'      => '销售起订数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'buy_min'       => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '采购起订数',
+            'default'   => '1',
+            'desc'      => '采购起订数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -74,9 +105,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})',
         ),
     ),
 
@@ -89,13 +120,39 @@ return array
 
     'request' => array
     (
+        # 后台搜索用到,也可以不加,自动生成
+        'search' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_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.*,t_2.id as value, "" as selected, "" as disabled',
+        ),
+
         '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'),
@@ -118,7 +175,7 @@ return array
             ),
             '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',
+            'col' => '*,t_2.*',
         ),
 
         'getDataPage' => array
@@ -127,7 +184,6 @@ return 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'),
@@ -151,7 +207,21 @@ return array
             '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',
+            'col' => '*,t_2.*',
+        ),
+
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*',
         ),
     ),
 );

+ 295 - 0
module/scm_seller/database/in_order.php

@@ -0,0 +1,295 @@
+<?php
+
+$status = array
+(
+    1 => array('name' => '待审核', 'style' => 'font-weight:bold;color:#436EEE'),
+    2 => array('name' => '已审核', 'style' => 'font-weight:bold;color:#003366'),
+    3 => array('name' => '已驳回', 'style' => 'font-weight:bold;color:#993333'),
+);
+
+$audit = array
+(
+    //1 => '待审核',
+    2 => '审核通过',
+    3 => '审核未通过',
+);
+
+$type = function() {
+    return Dever::db('scm_seller/in_order_type')->state();
+};
+
+$shop = array();
+$seller_id = Dever::input('search_option_seller_id');
+if ($seller_id) {
+	$shop = function() use($seller_id) {
+		return Dever::db('scm_seller/shop')->state(array('seller_id' => $seller_id, 'status' => 1));
+	};
+}
+
+$source_type = array
+(
+    1 => '供应商',
+    2 => '配送商仓库',
+    3 => '经销商门店',
+    10 => '其他',
+);
+
+$seller = function() {
+    return Dever::db('scm_seller/info')->state();
+};
+
+$col = Dever::input('col');
+
+return array
+(
+    # 表名
+    'name' => 'in_order',
+    # 显示给用户看的名称
+    'lang' => '入库单查询',
+    'order' => 10,
+    'set' => array
+    (
+    	'status' => $status,
+        'audit' => $audit,
+    ),
+    'end' => array
+    (
+        'insert' => 'scm/lib/order.updateOrderNum?table=scm_seller/in_order&prefix=CI',
+        'update' => 'scm/lib/stock.update_commit?table=scm_seller/in_order&stock=scm_seller/shop_goods&type=in&col=seller_shop_id',
+    ),
+
+    # 数据结构
+    '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_seller/lib/manage.info", "in", {id})',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '配送商',
+            'default'   => '',
+            'desc'      => '配送商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'searchs'    => array
+            (
+                'api' => 'scm_role/seller-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'search'    => 'select',
+            'option'    => $seller,
+            'value'     => $seller_id,
+            //'list'      => 'Dever::load("scm_seller/info-one#name", {seller_id})',
+        ),
+
+        'seller_shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '仓库',
+            'default'   => '',
+            'desc'      => '仓库',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $shop,
+            //'list'      => 'Dever::load("scm_seller/shop-one#name", {seller_shop_id})',
+        ),
+
+        'source_type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '来源类型',
+            'default'   => '1',
+            'desc'      => '来源类型',
+            'match'     => 'is_numeric',
+        ),
+
+        'source_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '来源',
+            'default'   => '',
+            'desc'      => '来源',
+            'match'     => 'is_numeric',
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '入库类型',
+            'default'   => '1',
+            'desc'      => '入库类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'search'    => 'select',
+            'option'    => $type,
+            //'list'      => true,
+        ),
+
+        'relate_order_num'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '关联单据号',
+            'default'   => '',
+            'desc'      => '关联单据号',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单备注',
+            'default'   => '',
+            'desc'      => '订单备注',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'address'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '收货信息',
+            'default'   => '',
+            'desc'      => '收货信息',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+            //'search'    => 'fulltext',
+            //'list'      => true,
+        ),
+
+        'scm_seller-in_order_goods'=> array
+		(
+			'name' 		=> '商品设置',
+			'default' 	=> '',
+			'desc' 		=> '商品设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'order_id'),
+			'update'	=> array(1),
+			# 1纵向展示 2横向展示
+			'update_type' => 2,
+            'list_name' => '商品信息',
+			'list'		=> 'Dever::load("scm_product/lib/manage.getGoods", {id}, "scm_seller/in_order_goods")',
+		),
+
+        'audit'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '审核状态',
+            'default'   => '2',
+            'desc'      => '审核状态',
+            'match'     => 'is_numeric',
+            'option'    => $audit,
+            'update'    => $col ? 'radio' : false,
+        ),
+
+        'audit_desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '审核备注',
+            'default'   => '',
+            'desc'      => '审核备注',
+            'match'     => 'option',
+            'update'    => $col ? 'textarea' : false,
+        ),
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '审核人',
+            //'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            //'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
+    (
+        # 后台提交时,检测该值是否为空,多个用逗号隔开
+        'update_check' => 'scm_seller-in_order_goods',
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        //'excel' => $excel,
+        //'mul' => $mul,
+
+        'button' => array
+        (
+            //'导出订单明细' => array('excel', 'shop/excel.sell_order'),
+            '类型配置' => array('list', 'in_order_type&oper_parent=in_order'),
+        ),
+
+        'list_button' => array
+        (
+            'list' => array('查看详情', '"in_order_goods&type=in&page_type=1&order_id={id}"'),
+
+            'fast' => array('审核', '"in_order&where_id={id}&col=audit,audit_desc"', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 226 - 0
module/scm_seller/database/in_order_goods.php

@@ -0,0 +1,226 @@
+<?php
+
+$status = array
+(
+    1 => '待审',
+    2 => '已审核',
+    3 => '未通过',
+);
+
+return array
+(
+    # 表名
+    'name' => 'in_order_goods',
+    # 显示给用户看的名称
+    'lang' => '订单商品表',
+    'menu' => false,
+    'status' => $status,
+    # 验证供应商商品是否存在
+    'start' => array
+    (
+        'insert' => 'scm_seller/lib/manage.check',
+    ),
+    'end' => array
+    (
+        'insert' => 'scm/lib/order.updateGoods?table=scm_seller/in_order_goods',
+        'update' => 'scm/lib/order.updateGoods?table=scm_seller/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-2000',
+            'name'      => '商品',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'option',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.searchProduct?{supplier_id}',
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showInfo?cash_col=buy_price', 'scm_product'), 'col' => 'seller_shop_id,source_type,source_id')),
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '库存',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'is_numeric',
+            'update'    => 'show',
+            'value'     => '暂无',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
+            'match'     => 'is_numeric',
+        ),
+
+        'shop_goods_list_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '关联仓库商品id',
+            'default'   => '',
+            'desc'      => '关联仓库商品id',
+            'match'     => 'is_numeric',
+            'value'     => '暂无',
+        ),
+
+        'unit_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '单位',
+            'default'   => '',
+            'desc'      => '单位',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => array(0 => '请先选择商品'),
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showPriceByUnit?cash_col=buy_price', 'scm_product'), 'col' => 'source_type,source_id,seller_shop_id,goods')),
+        ),
+
+        'batch'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '入库批次号',
+            'default'   => '',
+            'desc'      => '批次号',
+            'match'     => 'option',
+            'update'    => 'text',
+            'value'     => date('Ymd'),
+        ),
+
+        'sdate'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '生产日期',
+            'default'   => '',
+            'desc'      => '生产日期',
+            'match'     => 'option',
+            'update'    => 'day',
+            'callback'  => 'maketime',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '单价',
+            'default'   => '',
+            'desc'      => '单价',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '数量',
+            'default'   => '1',
+            'desc'      => '数量',
+            'match'     => 'option',
+            '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,
+        'page_list' => 'order_goods',
+    ),
+
+    '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', '<='),
+                'seller_id' => array('yes-t_2.seller_id'),
+                'seller_shop_id' => array('yes-t_2.seller_shop_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_seller/in_order',
+                    'type' => 'left join',
+                    'on' => array('order_id','id'),
+                ),
+            ),
+            'type' => 'all',
+            'group' => 't_2.seller_id, t_2.seller_shop_id, t_1.goods_id',
+            'col' => 'id,t_2.seller_id, t_2.seller_shop_id, t_1.goods_id,sum(t_1.num) as num',
+        ),
+    ),
+);

+ 106 - 0
module/scm_seller/database/in_order_type.php

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

+ 102 - 105
module/scm_seller/database/info.php

@@ -11,17 +11,6 @@ $type = function()
 	return $array;
 };
 
-$seller = function()
-{
-	$array = array();
-	$data = Dever::load('scm_seller/info-state');
-	if($data)
-	{
-		$array += $data;
-	}
-	return $array;
-};
-
 $category = function()
 {
 	$array = array();
@@ -47,10 +36,16 @@ $price = function()
     return $array;
 };
 
-$sell_goods = array
+$func = array
 (
-	1 => '经销所有商品',
-	2 => '经销部分商品',
+    'base' => '基础运营',
+    'news' => '文章资讯',
+    'agent' => '分销代理',
+	'product' => '平台商品',
+    'resource' => '平台资源',
+    'self_product' => '自营商品',
+    'self_resource' => '自营资源',
+    'yuding' => '场地预定',
 );
 
 $identity = array
@@ -60,12 +55,6 @@ $identity = array
 	3 => '企业',
 );
 
-$stock = array
-(
-	1 => '独立库存',
-	2 => '共享库存',
-);
-
 $status = array
 (
     1 => '启用',
@@ -79,11 +68,12 @@ $account = function() {
 return array
 (
 	# 表名
-	'name' => 'seller',
+	'name' => 'info',
 	# 显示给用户看的名称
 	'lang' => '经销商列表',
 	# 是否显示在后台菜单
-	'order' => 11,
+	'order' => 100,
+    'check' => 'code',
 
 	# 数据结构
 	'struct' => array
@@ -95,7 +85,7 @@ return array
 			'default' 	=> '',
 			'desc' 		=> '',
 			'match' 	=> 'is_numeric',
-			'list'		=> true,
+			//'list'		=> true,
 			'order'		=> 'asc',
 		),
 
@@ -143,78 +133,87 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $type,
-            'list'		=> true,
+            //'list'		=> true,
+        ),
+
+        'scm_seller-shop'=> array
+        (
+            'name'      => '门店设置',
+            'default'   => '',
+            'desc'      => '门店设置',
+            'match'     => 'option',
+            # 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+            'sync'      => array('id', 'seller_id'),
+            'update'    => array(1),
+            # 1纵向展示 2横向展示
+            'update_type' => 2,
+            'list_name' => '门店列表',
+            'list'      => 'Dever::load("scm_seller/lib/manage.getShop", {id})',
         ),
 
         'account'      => array
         (
             'type'      => 'varchar-800',
-            'name'      => '选择账户',
+            'name'      => '资金账户-可以选择多个资金账户,账户余额可用于提现和分销',
             'default'   => '',
-            'desc'      => '选择账户',
+            'desc'      => '资金账户',
             'match'     => 'is_string',
             'update'    => 'checkbox',
             'option'    => $account,
-            'list_name' => '账户信息',
-            'list'      => 'Dever::load("account/api.getInfo", {id}, "{account}")',
+            'tab'       => 1,
+            //'list_name' => '账户信息',
+            //'list'      => 'Dever::load("account/api.getInfo", {id}, "{account}")',
         ),
 
-        'stock'        => array
+        'func'      => array
         (
-            'type'      => 'tinyint-1',
-            'name'      => '库存设置-如果商品有库存,这里设置库存是否独立或共享,独立库存就是该经销商自己使用一套库存,共享库存就是和其他经销商共享一套库存,共享库存将无法设置商品',
-            'default'   => '1',
-            'desc'      => '库存设置',
-            'match'     => 'is_numeric',
-            //'update'    => 'radio',
-            'option'    => $stock,
-            'control'	=> 'stock',
+            'type'      => 'varchar-2000',
+            'name'      => '基础功能',
+            'default'   => 'base',
+            'desc'      => '基础功能',
+            'match'     => 'is_string',
+            'update'    => 'checkbox',
+            'option'    => $func,
+            'tab'       => 1,
+            'control'   => 'func',
         ),
 
-        'stock_seller'        => array
+        'category'      => array
         (
-            'type'      => 'int-11',
-            'name'      => '共享经销商-选择和哪个经销商共享一套库存',
-            'default'   => '-1',
-            'desc'      => '共享经销商',
-            'match'     => 'is_numeric',
-            //'update'    => 'select',
-            'option'    => $seller,
-            'show'		=> 'stock=2'
+            'type'      => 'varchar-2000',
+            'name'      => '平台商品属性分类-如不选择就是可以销售所有商品属性分类下的商品',
+            'default'   => '',
+            'desc'      => '商品属性分类',
+            'match'     => 'is_string',
+            'update'    => 'checkbox',
+            'option'    => $category,
+            'tab'       => 1,
+            'show'      => 'func=product',
         ),
 
-        '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'      => '商品价格模板',
+            'name'      => '平台商品价格模板',
             'default'   => '-1',
-            'desc'      => '商品价格模板',
+            'desc'      => '平台商品价格模板',
             'match'     => 'is_numeric',
             'update'    => 'select',
             'option'    => $price,
-            'show'      => 'stock=1'
+            'tab'       => 1,
+            'show'      => 'func=product',
         ),
 
         'commission'        => array
         (
             'type'      => 'varchar-20',
-            'name'      => '销售佣金调整-针对每个商品的销售佣金做统一调整,如填写5%,就是在原有销售佣金的基础上增加5%佣金,不设置则不做任何调整,设置为0,则佣金为0',
+            'name'      => '销售佣金调整-针对每个商品的销售佣金做统一调整,如填写5%,就是在原有销售佣金的基础上增加5%佣金,设置为0则不做任何调整,设置为no,则佣金为0',
             'default'   => '0',
             'desc'      => '销售佣金调整',
             'match'     => 'option',
             'update'    => 'text',
+            'tab'       => 1,
+            'show'      => 'func=agent',
         ),
 
 		'truename'      => array
@@ -226,7 +225,7 @@ return array
             'match'     => 'is_string',
             'update'    => 'text',
             'search'    => 'fulltext',
-            'tab'		=> 1,
+            'tab'		=> 2,
         ),
 
         'mobile'      => array
@@ -238,21 +237,21 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'text',
             'search'    => 'fulltext',
-            'tab'		=> 1,
+            'tab'		=> 2,
         ),
 
         'area'       => array
         (
             'type'      => 'varchar-500',
-            'name'      => '联系人城市',
+            'name'      => '联系人所在区县',
             'default'   => '',
-            'desc'      => '联系人城市',
+            '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,
+            'tab'		=> 2,
         ),
 
         'province'      => array
@@ -263,7 +262,7 @@ return array
             'desc'      => '省份',
             'match'     => 'option',
             //'update'  => 'text',
-            'tab'		=> 1,
+            'tab'       => 2,
         ),
 
         'city'      => array
@@ -274,7 +273,7 @@ return array
             'desc'      => '城市',
             'match'     => 'option',
             //'update'  => 'text',
-            'tab'		=> 1,
+            'tab'       => 2,
         ),
 
         'county'      => array
@@ -285,19 +284,19 @@ return array
             'desc'      => '县区',
             'match'     => 'option',
             //'update'  => 'text',
-            'tab'		=> 1,
+            'tab'       => 2,
         ),
 
         'address'       => array
         (
             'type'      => 'varchar-1000',
-            'name'      => '联系人地址',
+            'name'      => '联系人详细地址',
             'default'   => '',
-            'desc'      => '联系人地址',
+            'desc'      => '联系人详细地址',
             'match'     => 'option',
             'update'    => 'text',
             //'list'        => true,
-            'tab'		=> 1,
+            'tab'		=> 2,
         ),
 
         'identity'        => array
@@ -310,7 +309,7 @@ return array
             'update'    => 'radio',
             'option'    => $identity,
             'control'	=> 'identity',
-            'tab'		=> 2,
+            'tab'		=> 3,
         ),
 
         'idcard_front'     => array
@@ -323,7 +322,7 @@ return array
             'update'    => 'image',
             'key'       => '8',
             'place'     => '660*660',
-            'tab'		=> 2,
+            'tab'		=> 3,
         ),
 
         'idcard_back'     => array
@@ -336,25 +335,13 @@ return array
             '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,
+            'tab'		=> 3,
         ),
 
         'company_license'     => array
         (
             'type'      => 'varchar-150',
-            'name'      => '企业营业执照',
+            'name'      => '营业执照',
             'default'   => '',
             'desc'      => '企业营业执照',
             'match'     => 'option',
@@ -362,19 +349,31 @@ return array
             'key'       => '8',
             'place'     => '660*660',
             'show'		=> 'identity=2,3',
-            'tab'		=> 2,
+            'tab'		=> 3,
         ),
 
-        'company_license_number'      => array
+        'company_name'      => array
         (
             'type'      => 'varchar-200',
-            'name'      => '企业营业执照号码',
+            'name'      => '企业全称',
             'default'   => '',
-            'desc'      => '营业执照号码',
+            'desc'      => '企业全称',
             'match'     => 'option',
-            'update'    => 'text',
-            'show'		=> 'identity=2,3',
-            'tab'		=> 2,
+            //'update'    => 'text',
+            'show'      => 'identity=2,3',
+            'tab'       => 3,
+        ),
+
+        'company_number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '社会信用代码',
+            'default'   => '',
+            'desc'      => '社会信用代码',
+            'match'     => 'option',
+            //'update'    => 'text',
+            'show'      => 'identity=2,3',
+            'tab'       => 3,
         ),
 
 		'reorder'		=> array
@@ -431,22 +430,20 @@ return array
 	'manage' => array
 	(
         'delete' => false,
-		'tab' => array('基本设置', '联系人信息', '认证信息'),
+		'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 />'),
-            'location2' => array('入库下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
-            'location3' => array('出库下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
-            'location1' => array('订货下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
-            'location4' => array('代客下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
+            'br1' => array('<br />'),
+            'location' => array('分配供应商', Dever::url('lib/set.home?role=seller', 'scm_supplier')),
+            'location1' => array('分配配送商', Dever::url('lib/set.home?role=seller', 'scm_servicer')),
+            'location2' => array('商品设置', Dever::url('lib/set.home?project=seller&table=goods&info=info', 'scm_product')),
+            'add' => array('采购下单', 'buy_order&oper_table=info&search_option_seller_id={id}&oper_save_jump=buy_order'),
             '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}'),
+            'list' => array('资金账户', 'info&project=account&oper_table=info&oper_project=scm_seller&search_option_uid={id}', '"{account}"'),
         )
 	),
 

+ 115 - 0
module/scm_seller/database/servicer.php

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

+ 282 - 0
module/scm_seller/database/shop.php

@@ -0,0 +1,282 @@
+<?php
+
+
+$stock = array
+(
+    1 => '独立库存',
+    2 => '共享库存',
+);
+$shop = function()
+{
+	$array = array();
+	$data = Dever::load('scm_seller/shop-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$type = array
+(
+	1 => '实体店',
+	2 => '网店',
+	3 => '虚拟店',
+);
+
+$status = array
+(
+	1 => '启用',
+	2 => '禁用',
+);
+
+$set = Dever::input('set', 2);
+
+return array
+(
+	# 表名
+	'name' => 'shop',
+	# 显示给用户看的名称
+	'lang' => '经销商门店',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+	'check' => 'seller_id,code',
+
+	'status' => $status,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'seller_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '经销商ID',
+			'default' 	=> '-1',
+			'desc' 		=> '经销商ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_seller_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,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '门店类型-实体店需要设置门店地址',
+            'default'   => '2',
+            'desc'      => '门店类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'		=> true,
+            'control'	=> 'type',
+        ),
+
+        'area'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '所在区县',
+            'default'   => '',
+            'desc'      => '所在区县',
+            'match'     => 'is_string',
+            'search'    => 'linkage',
+            'update'    => $set == 1 ? 'linkage' : false,
+            'option'    => Dever::url('api.get?level_total=3', 'area'),
+            //'list'      => 'Dever::load("area/api.string", "{area}")',
+            'show'		=> 'type=1',
+        ),
+
+        'address'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '详细地址',
+            'default'   => '',
+            'desc'      => '详细地址',
+            'match'     => 'is_string',
+            'update'    => $set == 1 ? 'text' : false,
+            'show'		=> 'type=1',
+        ),
+
+        'truename'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '联系人姓名',
+            'default'   => '',
+            'desc'      => '请输入联系人姓名',
+            'match'     => 'is_string',
+            'update'    => $set == 1 ? 'text' : false,
+            'search'    => 'fulltext',
+            'show'		=> 'type=1',
+        ),
+
+        'tel'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人电话',
+            'default'   => '',
+            'desc'      => '请输入联系人电话',
+            'match'     => 'is_numeric',
+            'update'    => $set == 1 ? 'text' : false,
+            'search'    => 'fulltext',
+            'show'		=> 'type=1',
+        ),
+
+        'stock'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '库存设置-如果商品有库存,这里设置库存是否独立或共享,独立库存就是该门店自己使用一套库存,共享库存就是和其他门店共享一套库存,共享库存将无法设置商品',
+            'default'   => '1',
+            'desc'      => '库存设置',
+            'match'     => 'is_numeric',
+            'update'    => $set == 1 ? 'radio' : false,
+            'option'    => $stock,
+            'control'	=> 'stock',
+            'tab'		=> 1,
+        ),
+
+        'stock_shop'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '共享门店-选择和哪个门店共享一套库存',
+            'default'   => '-1',
+            'desc'      => '共享经销商',
+            'match'     => 'is_numeric',
+            'update'    => $set == 1 ? 'select' : false,
+            'option'    => $shop,
+            'show'		=> 'stock=2',
+            'tab'		=> 1,
+        ),
+
+        'company_license'     => 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',
+            'tab'       => 2,
+        ),
+
+        'company_number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '社会信用代码',
+            'default'   => '',
+            'desc'      => '社会信用代码',
+            'match'     => 'option',
+            'update'    => 'text',
+            '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' 		=> '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
+	(
+		'tab' => array('基本信息', '商品设置', '门店认证'),
+		'delete' => false,
+        
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 115 - 146
module/scm_seller/database/goods_sku.php → module/scm_seller/database/shop_goods.php

@@ -1,24 +1,18 @@
 <?php
 
-$config = array
+return array
 (
     # 表名
-    'name' => 'goods_sku',
+    'name' => 'shop_goods',
     # 显示给用户看的名称
-    'lang' => '商品价格设置',
-    'order' => 200,
-    'menu' => false,
-    /*
-    'end' => array
-    (
-        'insert' => 'scm_role/lib/seller.skuUpdate',
-        'update' => 'scm_role/lib/seller.skuUpdate',
-    ),
-    */
+    'lang' => '门店商品列表',
+    'order' => 10,
+    'menu'  => false,
 
-    # 数据结构 不同的字段放这里
+    # 数据结构
     'struct' => array
     (
+    
         'id'        => array
         (
             'type'      => 'int-11',
@@ -26,23 +20,25 @@ $config = array
             'default'   => '',
             'desc'      => '',
             'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
             //'list'        => true,
         ),
 
-        'seller_id'      => array
+        'seller_shop_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '所属销售商',
+            'name'      => '经销商门店',
             'default'   => '',
-            'desc'      => '所属销售商',
+            '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})',
+            'value'     => Dever::input('search_option_seller_shop_id'),
+            'list'      => 'Dever::load("scm_seller/shop-one#name", {seller_shop_id})',
         ),
 
-        'goods-info_sku-code'=> array
+        'scm_product-info_sku-code'=> array
         (
             'name'      => '商品编码',
             'default'   => '',
@@ -50,8 +46,14 @@ $config = array
             'match'     => 'option',
             # 读取另外表的关联方式
             'sync'      => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
+            'search'    => array
+            (
+                'api' => 'scm_product/info_sku-all',
+                'col' => 'code',
+                'result' => 'id',
+                'search' => 'sku_id',
+            ),
             'list'      => true,
-            'list_order' => 4,
         ),
 
         'goods_id'      => array
@@ -61,9 +63,16 @@ $config = array
             'default'   => '',
             'desc'      => '商品名称',
             'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'scm_product/info-all',
+                'col' => 'name',
+                'result' => 'id',
+                'search' => 'goods_id',
+            ),
             'update'    => 'select',
             'update_search' => 'scm_product/lib/manage.search',
-            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+            'list'      => 'Dever::load("scm_product/lib/info.getBaseInfo#aname", "{goods_id}", "{sku_id}")',
         ),
 
         'sku_id'      => array
@@ -75,54 +84,65 @@ $config = array
             'match'     => 'is_numeric',
         ),
 
+        'unit_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '基本单位',
+            'default'   => '',
+            'desc'      => '基本单位',
+            'match'     => 'is_numeric',
+            'list'      => 'Dever::load("scm/unit-one#name", {unit_id})',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库均价',
+            'default'   => '',
+            'desc'      => '入库均价',
+            'match'     => 'option',
+            'list'      => true,
+        ),
+
         'in_num'        => array
         (
             'type'      => 'decimal-11,2',
-            'name'      => '入库库存',
+            'name'      => '入库库存',
             'default'   => '0',
-            'desc'      => '入库库存',
+            'desc'      => '入库库存',
             'match'     => 'is_numeric',
+            'list'      => true,
         ),
 
         'out_num'      => array
         (
             'type'      => 'decimal-11,2',
-            'name'      => '出库库存',
+            'name'      => '出库库存',
             'default'   => '0',
-            'desc'      => '出库库存',
+            'desc'      => '出库库存',
             'match'     => 'option',
-        ),
-
-        'min'       => array
-        (
-            'type'      => 'float-11,2',
-            'name'      => '起购数',
-            'default'   => '1',
-            'desc'      => '起购数',
-            'match'     => 'is_string',
-            'update'    => 'text',
-            //'list'      => true,
+            'list'      => true,
         ),
 
         'state'     => array
         (
             'type'      => 'tinyint-1',
-            'name'      => '数据状态',
+            'name'      => '状态',
             'default'   => '1',
             'desc'      => '请选择状态',
             'match'     => 'is_numeric',
         ),
-
+        
         'cdate'     => array
         (
             'type'      => 'int-11',
-            'name'      => '发布时间',
+            'name'      => '创建时间',
             'match'     => array('is_numeric', time()),
             'desc'      => '',
             # 只有insert时才生效
             'insert'    => true,
-            //'search'  => 'date',
-            //'list'        => 'date("Y-m-d H:i:s", {cdate})',
+            //'search'    => 'date',
+            //'list'      => 'date("Y-m-d H:i:s", {cdate})',
         ),
     ),
 
@@ -131,28 +151,25 @@ $config = array
         'insert' => false,
         'edit' => false,
         'delete' => false,
-        //'excel' => array(array('导出门店库存', '门店库存', '')),
-        'page_list_table' => 'sku',
+        'list_button' => array
+        (
+            'list' => array('查看详情', '"shop_goods_list&oper_table=shop_goods&top_table=info&search_option_shop_goods_id={id}"'),
+        ),
     ),
 
-    # request 请求接口定义
     'request' => array
     (
-        'getDataPage' => array
+        # 后台搜索用到,也可以不加,自动生成
+        'search' => 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),
+                'seller_shop_id' => array('yes-t_1.seller_shop_id'),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
             ),
             # 联表
             'join' => array
@@ -167,8 +184,8 @@ $config = array
             ),
             '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',
+            'page' => array(10, 'list'),
+            'col' => '*, t_2.*,t_2.id as value, "" as selected, "" as disabled',
         ),
 
         'getData' => array
@@ -176,16 +193,16 @@ $config = array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'seller_id' => array('yes-t_1.seller_id'),
+                'seller_shop_id' => array('yes-t_1.seller_shop_id'),
+                'sell_type' => array('yes-t_2.sell_type'),
                 '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),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
             ),
             # 联表
             'join' => array
@@ -200,118 +217,70 @@ $config = array
             ),
             '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',
+            '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',
         ),
 
-       	# 列表
-        'getList' => array
+        'getDataPage' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'seller_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
-                'state' => 1,
+                'seller_shop_id' => array('yes-t_1.seller_shop_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('id' => 'desc'),
-            'col' => '*,in_num-out_num as total|sku_id',
+            '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',
         ),
 
-        # 获取单条数据
+        # 获取某个sku的单条数据
         'getOne' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'seller_id' => 'yes',
+                'seller_shop_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', '+='),
-            ),
+            'col' => '*,(sum(in_num)-sum(out_num)) as total,AVG(cash) as cash',
         ),
 
-        # 减少总库存
-        'decTotal' => array
+        # 获取单位下的数据
+        'getUnit' => array
         (
-            'type' => 'update',
-            'where' => array
+            # 匹配的正则或函数 选填项
+            'option' => array
             (
-                'seller_id' => 'yes',
+                'seller_shop_id' => 'yes',
                 'goods_id' => 'yes',
                 'sku_id' => 'yes',
+                'state' => 1,
             ),
-            'set' => array
-            (
-                'in_num' => array('yes', '-='),
-            ),
+            'type' => 'all',
+            'col' => '*,(in_num-out_num) as total|unit_id',
         ),
     ),
 );
-
-return $config;

+ 245 - 0
module/scm_seller/database/shop_goods_list.php

@@ -0,0 +1,245 @@
+<?php
+
+$info = '';
+$shop_goods_id = Dever::input('search_option_shop_goods_id');
+if ($shop_goods_id) {
+    $shop_goods = Dever::db('scm_seller/shop_goods')->find($shop_goods_id);
+    if ($shop_goods) {
+        $shop = Dever::db('scm_seller/shop')->find($shop_goods['seller_shop_id']);
+        $seller = Dever::db('scm_seller/info')->find($shop['seller_id']);
+        $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($shop_goods['goods_id'], $shop_goods['sku_id']);
+        $info = '<blockquote class="layui-elem-quote">';
+        $info .= $seller['name'] . '.' . $shop['name'];
+        $info .= ' -> ';
+        $info .= '<b>' . $goods_info['aname'] . '('.$goods_info['code'].')</b>';
+        $info .= '<br />';
+        $info .= '入库均价:' . '<b>' . $shop_goods['cash'] . '</b>';
+        $info .= ' 入库总库存:' . '<b>' . $shop_goods['in_num'] . '</b>';
+        $info .= ' 出库总库存:' . '<b>' . $shop_goods['out_num'] . '</b>';
+        $info .= '</blockquote>';
+    }
+}
+$config = array
+(
+    # 表名
+    'name' => 'shop_goods_list',
+    # 显示给用户看的名称
+    'lang' => '商品价格设置',
+    'order' => 200,
+    'menu' => false,
+    'info' => $info,
+
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'seller_shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属配送商',
+            'default'   => '',
+            'desc'      => '所属配送商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_seller_shop_id'),
+            //'list'      => 'Dever::load("scm_seller/shop-one#name", {seller_shop_id})',
+        ),
+
+        'shop_goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品id',
+            'default'   => '',
+            'desc'      => '商品id',
+            'match'     => 'is_numeric',
+        ),
+
+        'batch'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '入库批次号',
+            'default'   => '',
+            'desc'      => '入库批次号',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'sdate'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '生产日期',
+            'default'   => '',
+            'desc'      => '生产日期',
+            'match'     => 'option',
+            'update'    => 'day',
+            'callback'  => 'maketime',
+            'search'    => 'day',
+            'list'      => '{sdate} ? date("Y-m-d H:i:s", {sdate}) : "-"',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库单价',
+            'default'   => '',
+            'desc'      => '入库单价',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'in_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库库存',
+            'default'   => '0',
+            'desc'      => '入库库存',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+
+        'out_num'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '出库库存',
+            'default'   => '0',
+            'desc'      => '出库库存',
+            'match'     => 'option',
+            '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
+    (
+       	# 列表 先入先出
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('sdate' => 'asc', 'batch' => 'asc', 'id' => 'asc'),
+            'col' => '*,in_num-out_num as total',
+        ),
+
+        # 获取某个仓库商品下的数据
+        'getOneByshop' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_goods_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'group' => 'shop_goods_id',
+            'col' => 'id,sum(in_num) as in_num, sum(out_num) as out_num,AVG(cash) as cash',
+        ),
+
+        # 更新入库库存
+        'inUpdate' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 更新出库库存
+        'outUpdate' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 更新入库在途库存
+        'onInUpdate' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'on_in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 更新出库在途库存
+        'onOutUpdate' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'on_out_num' => array('yes', '+='),
+            ),
+        ),
+    ),
+);
+
+return $config;

+ 115 - 0
module/scm_seller/database/shop_store.php

@@ -0,0 +1,115 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'shop_store',
+    # 显示给用户看的名称
+    'lang' => '门店仓库配送关系表',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'shop_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '门店ID',
+			'default' 	=> '-1',
+			'desc' 		=> '门店ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_shop_id'),
+		),
+
+        'servicer_store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '仓库ID',
+            'default'   => '',
+            'desc'      => '仓库ID',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_servicer_store_id'),
+            'list'      => 'Dever::load("scm_supplier/store-one#name", {servicer_store_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
+            (
+                'seller_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*|servicer_store_id',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_servicer/info',
+                    'type' => 'left join',
+                    'on' => array('servicer_store_id','id'),
+                    'col' => 'servicer_store_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'col' => '*,t_2.name,t_2.id as id|id',
+        ),
+    ),
+);

+ 115 - 0
module/scm_seller/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,
+        ),
+
+        'seller_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '经销商ID',
+			'default' 	=> '-1',
+			'desc' 		=> '经销商ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_seller_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
+            (
+                'seller_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*|supplier_id',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_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,t_2.id as id|id',
+        ),
+    ),
+);

+ 108 - 0
module/scm_seller/lib/Manage.php

@@ -0,0 +1,108 @@
+<?php
+
+namespace Scm_seller\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取订单信息
+    public function info($type = 'in', $id)
+    {
+        $info = Dever::db('scm_seller/'.$type.'_order')->find($id);
+
+        $string = '';
+
+        $string = $info['order_num'];
+
+        $seller = Dever::db('scm_seller/info')->one($info['seller_id']);
+
+        $string .= '<br />' . $seller['name'];
+
+        $shop = Dever::db('scm_seller/shop')->one($info['seller_shop_id']);
+
+        $string .= '.' . $shop['name'];
+
+        if (isset($info['supplier_id'])) {
+            $supplier = Dever::db('scm_supplier/info')->one($info['supplier_id']);
+
+            $string .= '<br />' . $supplier['name'];
+        }
+
+        if (isset($info['servicer_id'])) {
+            $servicer = Dever::db('scm_servicer/info')->one($info['servicer_id']);
+
+            $string .= '<br />' . $servicer['name'];
+
+            if (isset($info['servicer_store_id'])) {
+	            $store = Dever::db('scm_servicer/store')->one($info['servicer_store_id']);
+
+	            $string .= '.' . $store['name'];
+	        }
+        }
+
+        if ($type == 'in' || $type == 'out') {
+        	$type = Dever::db('scm_seller/'.$type.'_order_type')->one($info['type']);
+        	$string .= '<br />' . $type['name'];
+        }
+
+        $string .= '<br />' . $info['info'];
+
+        return $string;
+    }
+
+    # 查看详情
+    public function show()
+    {
+        $type = Dever::input('type');
+        return Dever::load('scm/lib/order')->show('scm_seller/'.$type.'_order', 'scm_seller/info', 'seller_id', '经销商');
+    }
+
+
+    public function getShop($id)
+    {
+        $table = array();
+        $table['head'] = array('门店名称', '门店编码', '操作');
+        $table['body'] = array();
+
+        $data = Dever::db('scm_seller/shop')->select(array('seller_id' => $id));
+
+        if ($data) {
+        	$status = Dever::db('scm_seller/shop')->config['status'];
+            foreach ($data as $k => $v) {
+            	$status_name = '';
+            	if ($v['status'] == 2) {
+            		$status_name = '(已禁用)';
+            	}
+            	$url = Dever::url('project/database/update?project=scm_seller&table=shop&oper_save_table=info&set=1&where_id='.$v['id'], 'manage');
+            	$oper = '<a class="layui-btn" onclick="fastEdit($(this),\''.$url.'\',\'编辑门店信息\', \'\')">编辑</a>';
+
+                $url = Dever::url('project/database/list?project=scm_seller&table=shop_goods&oper_table=info&search_option_seller_shop_id='.$v['id'], 'manage');
+            	$oper .= '<a class="layui-btn" href="'.$url.'">商品清单</a>';
+
+                $url = Dever::url('lib/set_store.home?role=seller&table=shop', 'scm_servicer');
+                $oper .= '<a class="layui-btn" href="'.$url.'">分配仓库</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 '暂无';
+        }
+    }
+}

+ 5 - 0
module/scm_seller/template/manage/order_goods.php

@@ -0,0 +1,5 @@
+<?php
+
+$view
+->fetch('#show', 'scm_seller/lib/manage.show')
+->display();

+ 341 - 0
module/scm_servicer/assets/pc/html/set_servicer.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>

+ 342 - 0
module/scm_servicer/assets/pc/html/set_store.html

@@ -0,0 +1,342 @@
+<!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}>';
+            var table = '<{$table}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {id:id, role:role,table:table, 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>

+ 1 - 1
module/scm_servicer/database/in_order.php

@@ -22,7 +22,7 @@ $store = array();
 $servicer_id = Dever::input('search_option_servicer_id');
 if ($servicer_id) {
 	$store = function() use($servicer_id) {
-		return Dever::db('scm_servicer/store')->state(array('servicer_id' => $servicer_id));
+		return Dever::db('scm_servicer/store')->state(array('servicer_id' => $servicer_id, 'status' => 1));
 	};
 }
 

+ 1 - 1
module/scm_servicer/database/in_order_goods.php

@@ -101,7 +101,7 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'select',
             'option'    => array(0 => '请先选择商品'),
-            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showPriceByUnit?cash_col=cost_price', 'scm_product'), 'col' => 'supplier_id,goods')),
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showPriceByUnit?cash_col=cost_price', 'scm_product'), 'col' => 'supplier_id,servicer_store_id,goods')),
         ),
 
         'batch'      => array

+ 0 - 10
module/scm_servicer/database/in_order_type.php

@@ -37,16 +37,6 @@ return array
 			'edit'		=> true,
 		),
 
-		'table'		=> array
-		(
-			'type' 		=> 'varchar-150',
-			'name' 		=> '关联表名-如该类型关联某个表,这里要加上表名,影响关联单据号',
-			'default' 	=> '',
-			'desc' 		=> '关联表名',
-			'match' 	=> 'is_string',
-			'update'	=> 'text',
-		),
-
 		'reorder'		=> array
 		(
 			'type' 		=> 'int-11',

+ 39 - 38
module/scm_servicer/database/info.php

@@ -1,24 +1,12 @@
 <?php
 $category = function()
 {
-    $array = array();
-    $data = Dever::load('scm_product/category-getTop');
-    if($data)
-    {
-        $array += $data;
-    }
-    return $array;
+    return Dever::load('scm_product/category-getTop');
 };
 
-$category = function()
+$type = function()
 {
-	$array = array();
-	$data = Dever::load('scm_product/category-getTop');
-	if($data)
-	{
-		$array += $data;
-	}
-	return $array;
+    return Dever::load('scm_servicer/type-state');
 };
 
 $identity = array
@@ -49,11 +37,11 @@ return array
 		'id' 		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> 'ID',
+			'name' 		=> '配送商ID',
 			'default' 	=> '',
 			'desc' 		=> '',
 			'match' 	=> 'is_numeric',
-			//'list'		=> true,
+			'list'		=> true,
 			//'order'		=> 'desc',
 		),
 
@@ -82,6 +70,18 @@ return array
             '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',
@@ -104,6 +104,7 @@ return array
 			'update'	=> array(1),
 			# 1纵向展示 2横向展示
 			'update_type' => 2,
+            'list_name' => '仓库列表',
 			'list'		=> 'Dever::load("scm_servicer/lib/manage.getStore", {id})',
 		),
 
@@ -241,24 +242,12 @@ return array
             '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'      => '企业营业执照',
+            'name'      => '营业执照',
             'default'   => '',
-            'desc'      => '企业营业执照',
+            'desc'      => '营业执照',
             'match'     => 'option',
             'update'    => 'image',
             'key'       => '8',
@@ -267,16 +256,28 @@ return array
             'tab'		=> 2,
         ),
 
-        'company_license_number'      => array
+        'company_name'      => array
         (
             'type'      => 'varchar-200',
-            'name'      => '企业营业执照号码',
+            'name'      => '企业全称',
             'default'   => '',
-            'desc'      => '营业执照号码',
+            'desc'      => '企业全称',
             'match'     => 'option',
-            'update'    => 'text',
-            'show'		=> 'identity=2,3',
-            'tab'		=> 2,
+            //'update'    => 'text',
+            'show'      => 'identity=2,3',
+            'tab'       => 2,
+        ),
+
+        'company_number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '社会信用代码',
+            'default'   => '',
+            'desc'      => '社会信用代码',
+            'match'     => 'option',
+            //'update'    => 'text',
+            'show'      => 'identity=2,3',
+            'tab'       => 2,
         ),
 
 		'reorder'		=> array
@@ -336,7 +337,7 @@ return array
 		'delete' => false,
 		'list_button' => array
         (
-        	'location' => array('供应商', Dever::url('lib/set.home?role=servicer', 'scm_supplier')),
+        	'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=in_order'),
             'add2' => array('出库下单', 'out_order&oper_table=info&search_option_servicer_id={id}&oper_save_jump=out_order'),

+ 1 - 1
module/scm_servicer/database/out_order_goods.php

@@ -18,7 +18,7 @@ return array
     # 验证库存
     'start' => array
     (
-    	'insert' => 'scm/lib/stock.out_check?table=scm_servicer/store_goods_list&order_table=scm_servicer/out_order&col=servicer_store_id',
+    	'insert' => 'scm/lib/stock.out_check?table=scm_servicer/store_goods&order_table=scm_servicer/out_order&col=servicer_store_id',
     ),
     'end' => array
     (

+ 0 - 10
module/scm_servicer/database/out_order_type.php

@@ -37,16 +37,6 @@ return array
 			'edit'		=> true,
 		),
 
-		'table'		=> array
-		(
-			'type' 		=> 'varchar-150',
-			'name' 		=> '关联表名-如该类型关联某个表,这里要加上表名,影响关联单据号',
-			'default' 	=> '',
-			'desc' 		=> '关联表名',
-			'match' 	=> 'is_string',
-			'update'	=> 'text',
-		),
-
 		'reorder'		=> array
 		(
 			'type' 		=> 'int-11',

+ 64 - 5
module/scm_servicer/database/store.php

@@ -5,6 +5,15 @@ $status = array
 	1 => '启用',
 	2 => '禁用',
 );
+
+$type = array
+(
+	1 => '实体仓',
+	2 => '虚拟仓',
+);
+
+$set = Dever::input('set', 2);
+
 return array
 (
 	# 表名
@@ -67,16 +76,66 @@ return array
             'list'      => true,
         ),
 
-        'address'      => array
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '门店类型-实体仓需要设置地址',
+            'default'   => '2',
+            'desc'      => '门店类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'		=> true,
+            'control'	=> 'type',
+        ),
+
+        'area'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '所在区县',
+            'default'   => '',
+            'desc'      => '所在区县',
+            'match'     => 'is_string',
+            'search'    => 'linkage',
+            'update'    => $set == 1 ? 'linkage' : false,
+            'option'    => Dever::url('api.get?level_total=3', 'area'),
+            //'list'      => 'Dever::load("area/api.string", "{area}")',
+            'show'		=> 'type=1',
+        ),
+
+        'address'       => array
         (
             'type'      => 'varchar-1000',
-            'name'      => '收货信息-用叹号隔开,格式如:收件地址、收件人名称、收件人电话',
+            'name'      => '详细地址',
             'default'   => '',
-            'desc'      => '收货信息',
+            'desc'      => '详细地址',
             'match'     => 'is_string',
-            'update'    => 'text',
+            'update'    => $set == 1 ? 'text' : false,
+            'show'		=> 'type=1',
+        ),
+
+        'truename'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '联系人姓名',
+            'default'   => '',
+            'desc'      => '请输入联系人姓名',
+            'match'     => 'is_string',
+            'update'    => $set == 1 ? 'text' : false,
             'search'    => 'fulltext',
-            'list'      => true,
+            'show'		=> 'type=1',
+        ),
+
+        'tel'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人电话',
+            'default'   => '',
+            'desc'      => '请输入联系人电话',
+            'match'     => 'is_numeric',
+            'update'    => $set == 1 ? 'text' : false,
+            'search'    => 'fulltext',
+            'show'		=> 'type=1',
         ),
 
 		'reorder'		=> array

+ 94 - 7
module/scm_servicer/database/store_goods.php

@@ -28,9 +28,9 @@ return array
         'servicer_store_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '所属配送商',
+            'name'      => '配送商仓库',
             'default'   => '',
-            'desc'      => '所属配送商',
+            'desc'      => '配送商仓库',
             'match'     => 'is_numeric',
             'update'    => 'hidden',
             'search'    => 'hidden',
@@ -38,7 +38,7 @@ return array
             'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_id})',
         ),
 
-        'goods-info_sku-code'=> array
+        'scm_product-info_sku-code'=> array
         (
             'name'      => '商品编码',
             'default'   => '',
@@ -46,8 +46,14 @@ return array
             'match'     => 'option',
             # 读取另外表的关联方式
             'sync'      => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
+            'search'    => array
+            (
+                'api' => 'scm_product/info_sku-all',
+                'col' => 'code',
+                'result' => 'id',
+                'search' => 'sku_id',
+            ),
             'list'      => true,
-            'list_order' => 4,
         ),
 
         'goods_id'      => array
@@ -57,9 +63,16 @@ return array
             'default'   => '',
             'desc'      => '商品名称',
             'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'scm_product/info-all',
+                'col' => 'name',
+                'result' => 'id',
+                'search' => 'goods_id',
+            ),
             'update'    => 'select',
             'update_search' => 'scm_product/lib/manage.search',
-            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+            'list'      => 'Dever::load("scm_product/lib/info.getBaseInfo#aname", "{goods_id}", "{sku_id}")',
         ),
 
         'sku_id'      => array
@@ -71,6 +84,46 @@ return array
             'match'     => 'is_numeric',
         ),
 
+        'unit_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '基本单位',
+            'default'   => '',
+            'desc'      => '基本单位',
+            'match'     => 'is_numeric',
+            'list'      => 'Dever::load("scm/unit-one#name", {unit_id})',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库均价',
+            'default'   => '',
+            'desc'      => '入库均价',
+            'match'     => 'option',
+            'list'      => true,
+        ),
+
+        'in_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库总库存',
+            'default'   => '0',
+            'desc'      => '入库总库存',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+
+        'out_num'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '出库总库存',
+            'default'   => '0',
+            'desc'      => '出库总库存',
+            'match'     => 'option',
+            'list'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -88,8 +141,8 @@ return array
             'desc'      => '',
             # 只有insert时才生效
             'insert'    => true,
-            'search'    => 'date',
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            //'search'    => 'date',
+            //'list'      => 'date("Y-m-d H:i:s", {cdate})',
         ),
     ),
 
@@ -98,6 +151,10 @@ return array
         'insert' => false,
         'edit' => false,
         'delete' => false,
+        'list_button' => array
+        (
+            'list' => array('查看详情', '"store_goods_list&oper_table=store_goods&top_table=info&search_option_store_goods_id={id}"'),
+        ),
     ),
 
     'request' => array
@@ -195,5 +252,35 @@ return array
             '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',
         ),
+
+        # 获取某个sku的单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*,(sum(in_num)-sum(out_num)) as total,AVG(cash) as cash',
+        ),
+
+        # 获取单位下的数据
+        'getUnit' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*,(in_num-out_num) as total|unit_id',
+        ),
     ),
 );

+ 36 - 35
module/scm_servicer/database/store_goods_list.php

@@ -1,5 +1,24 @@
 <?php
 
+$info = '';
+$store_goods_id = Dever::input('search_option_store_goods_id');
+if ($store_goods_id) {
+    $store_goods = Dever::db('scm_servicer/store_goods')->find($store_goods_id);
+    if ($store_goods) {
+        $store = Dever::db('scm_servicer/store')->find($store_goods['servicer_store_id']);
+        $servicer = Dever::db('scm_servicer/info')->find($store['servicer_id']);
+        $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($store_goods['goods_id'], $store_goods['sku_id']);
+        $info = '<blockquote class="layui-elem-quote">';
+        $info .= $servicer['name'] . '.' . $store['name'];
+        $info .= ' -> ';
+        $info .= '<b>' . $goods_info['aname'] . '('.$goods_info['code'].')</b>';
+        $info .= '<br />';
+        $info .= '入库均价:' . '<b>' . $store_goods['cash'] . '</b>';
+        $info .= ' 入库总库存:' . '<b>' . $store_goods['in_num'] . '</b>';
+        $info .= ' 出库总库存:' . '<b>' . $store_goods['out_num'] . '</b>';
+        $info .= '</blockquote>';
+    }
+}
 $config = array
 (
     # 表名
@@ -8,6 +27,7 @@ $config = array
     'lang' => '商品价格设置',
     'order' => 200,
     'menu' => false,
+    'info' => $info,
 
 
     # 数据结构 不同的字段放这里
@@ -33,28 +53,18 @@ $config = array
             'update'    => 'hidden',
             'search'    => 'hidden',
             'value'     => Dever::input('search_option_servicer_store_id'),
-            'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_id})',
+            //'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_id})',
         ),
 
         'store_goods_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '仓库商品id',
+            'name'      => '商品id',
             'default'   => '',
-            'desc'      => '仓库商品id',
+            'desc'      => '商品id',
             'match'     => 'is_numeric',
         ),
 
-        'unit_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '单位',
-            'default'   => '',
-            'desc'      => '单位',
-            'match'     => 'is_numeric',
-            //'update'    => 'select',
-        ),
-
         'batch'      => array
         (
             'type'      => 'varchar-800',
@@ -62,6 +72,8 @@ $config = array
             'default'   => '',
             'desc'      => '入库批次号',
             'match'     => 'option',
+            'search'    => 'fulltext',
+            'list'      => true,
         ),
 
         'sdate'      => array
@@ -73,6 +85,8 @@ $config = array
             'match'     => 'option',
             'update'    => 'day',
             'callback'  => 'maketime',
+            'search'    => 'day',
+            'list'      => '{sdate} ? date("Y-m-d H:i:s", {sdate}) : "-"',
         ),
 
         'cash'      => array
@@ -82,6 +96,8 @@ $config = array
             'default'   => '',
             'desc'      => '入库单价',
             'match'     => 'option',
+            'search'    => 'fulltext',
+            'list'      => true,
         ),
 
         'in_num'        => array
@@ -91,6 +107,7 @@ $config = array
             'default'   => '0',
             'desc'      => '入库库存',
             'match'     => 'is_numeric',
+            'list'      => true,
         ),
 
         'out_num'      => array
@@ -100,6 +117,7 @@ $config = array
             'default'   => '0',
             'desc'      => '出库库存',
             'match'     => 'option',
+            'list'      => true,
         ),
 
         'state'     => array
@@ -152,35 +170,18 @@ $config = array
             'col' => '*,in_num-out_num as total',
         ),
 
-        # 获取某个sku的单条数据
-        'getOne' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'servicer_store_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
-                'state' => 1,
-            ),
-            'type' => 'one',
-            'col' => '*,(sum(in_num)-sum(out_num)) as total,AVG(cash) as cash',
-        ),
-
-        # 获取单位下的数据
-        'getUnit' => array
+        # 获取某个仓库商品下的数据
+        'getOneByStore' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'servicer_store_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
+                'store_goods_id' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
-            'group' => 'unit_id',
-            'col' => '*,(sum(in_num)-sum(out_num)) as total,AVG(cash) as cash|unit_id',
+            'group' => 'store_goods_id',
+            'col' => 'id,sum(in_num) as in_num, sum(out_num) as out_num,AVG(cash) as cash',
         ),
 
         # 更新入库库存

+ 105 - 0
module/scm_servicer/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
+	(
+		
+	)
+);

+ 5 - 1
module/scm_servicer/lib/Manage.php

@@ -68,7 +68,11 @@ class Manage
             	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>';
+                $url = Dever::url('project/database/update?project=scm_servicer&table=store&oper_save_table=info&set=1&where_id='.$v['id'], 'manage');
+                $oper = '<a class="layui-btn" onclick="fastEdit($(this),\''.$url.'\',\'编辑仓库信息\', \'\')">编辑</a>';
+
+                $url = Dever::url('project/database/list?project=scm_servicer&table=store_goods&oper_table=info&top_table1=info&search_option_servicer_store_id='.$v['id'], 'manage');
+            	$oper .= '<a class="layui-btn" href="'.$url.'">库存清单</a>';
                 $table['body'][$k][] = $v['name'] . $status_name;
                 $table['body'][$k][] = $v['code'];
                 $table['body'][$k][] = $oper;

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

@@ -0,0 +1,112 @@
+<?php
+
+namespace Scm_servicer\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.'/servicer')->getAll(array($role . '_id' => $id));
+        $type = Dever::db('scm_servicer/type')->select();
+        
+        $result = array();
+        if ($type) {
+            $i = 0;
+            foreach ($type as $k => $v) {
+                $servicer = Dever::db('scm_servicer/info')->select(array('status' => 1, 'type_id' => $v['id']));
+                if ($servicer) {
+                    $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 ($servicer 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_servicer');
+        $data['url'] = Dever::url('lib/set.getList?id=' . $data['id'] . '&role=' . $data['role'], 'scm_servicer');
+        $data['search'] = Dever::url('lib/set.search?yes='.$data['id'].'&role=' . $data['role'] . '&json=1', 'scm_servicer');
+        $data['submit'] = Dever::url('lib/set.set_commit?json=1', 'scm_servicer');
+
+        return Dever::render('set_servicer', $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 . '/servicer';
+        $where['option_' . $col] = $id;
+        $where['set_state'] = 2;
+        Dever::db($table)->updates($where);
+
+        foreach ($value as $k => $v) {
+            $w = array();
+            $w['servicer_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';
+    }
+}

+ 117 - 0
module/scm_servicer/lib/Set_store.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace Scm_servicer\Lib;
+
+use Dever;
+
+class Set_store
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取下游
+    public function search_api()
+    {
+        $role = Dever::input('role');
+        $table = Dever::input('table');
+        $yes = Dever::input('yes');
+        $where = array();
+        $info = Dever::db('scm_' . $role . '/' . $table)->find($yes);
+        $where[$role . '_id'] = $info[$role . '_id'];
+        return Dever::search('scm_' . $role . '/' . $table, $where);
+    }
+
+    # 分配配送商
+    public function getList_api()
+    {
+        $role = Dever::input('role');
+        $table = Dever::input('table');
+        $id = Dever::input('id', 1);
+        $data = Dever::db('scm_'.$role.'/'.$table.'_store')->getAll(array($role . '_' . $table . '_id' => $id));
+        $type = Dever::db('scm_servicer/info')->select();
+        
+        $result = array();
+        if ($type) {
+            $i = 0;
+            foreach ($type as $k => $v) {
+                $store = Dever::db('scm_servicer/store')->select(array('status' => 1, 'servicer_id' => $v['id']));
+                if ($store) {
+                    $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 ($store 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['table'] = Dever::input('table');
+        $data['name'] = '门店';
+        $data['host'] = Dever::url('lib/set_store.home?role=' . $data['role'] . '&table=' . $data['table'], 'scm_servicer');
+        $data['url'] = Dever::url('lib/set_store.getList?id=' . $data['id'] . '&role=' . $data['role'] . '&table=' . $data['table'], 'scm_servicer');
+        $data['search'] = Dever::url('lib/set_store.search?yes='.$data['id'].'&role=' . $data['role'] . '&table=' . $data['table'] . '&json=1', 'scm_servicer');
+        $data['submit'] = Dever::url('lib/set_store.set_commit?json=1', 'scm_servicer');
+
+        return Dever::render('set_store', $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');
+        $table = Dever::input('table');
+
+        $col = $role . '_' . $table . '_id';
+        $table = 'scm_' . $role . '/' . $table . '_store';
+        $where['option_' . $col] = $id;
+        $where['set_state'] = 2;
+        Dever::db($table)->updates($where);
+
+        foreach ($value as $k => $v) {
+            $w = array();
+            $w[$role . '_' . $table . '_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';
+    }
+}

+ 2 - 2
module/scm_supplier/assets/pc/html/set_supplier.html

@@ -38,14 +38,14 @@
         <div class="main_right layui-col-xs12 layui-col-md9">
             <div class="layui-row">
                 <div class="top">
-                    <label>选择<{$name}>:</label>
+                    <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>
+                        <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;">

+ 23 - 23
module/scm_supplier/database/info.php

@@ -50,7 +50,7 @@ return array
 		'id' 		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> 'ID',
+			'name' 		=> '供应商ID',
 			'default' 	=> '',
 			'desc' 		=> '',
 			'match' 	=> 'is_numeric',
@@ -145,9 +145,9 @@ return array
         'area'       => array
         (
             'type'      => 'varchar-500',
-            'name'      => '联系人城市',
+            'name'      => '联系人所在区县',
             'default'   => '',
-            'desc'      => '联系人城市',
+            'desc'      => '联系人所在区县',
             'match'     => 'option',
             'search'    => 'linkage',
             'update'    => 'linkage',
@@ -192,9 +192,9 @@ return array
         'address'       => array
         (
             'type'      => 'varchar-1000',
-            'name'      => '联系人地址',
+            'name'      => '联系人详细地址',
             'default'   => '',
-            'desc'      => '联系人地址',
+            'desc'      => '联系人详细地址',
             'match'     => 'option',
             'update'    => 'text',
             //'list'        => true,
@@ -240,24 +240,12 @@ return array
             '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'      => '企业营业执照',
+            'name'      => '营业执照',
             'default'   => '',
-            'desc'      => '企业营业执照',
+            'desc'      => '营业执照',
             'match'     => 'option',
             'update'    => 'image',
             'key'       => '8',
@@ -266,14 +254,26 @@ return array
             'tab'		=> 2,
         ),
 
-        'company_license_number'      => array
+        'company_name'      => array
         (
             'type'      => 'varchar-200',
-            'name'      => '企业营业执照号码',
+            'name'      => '企业全称',
             'default'   => '',
-            'desc'      => '营业执照号码',
+            'desc'      => '企业全称',
             'match'     => 'option',
-            'update'    => 'text',
+            //'update'    => 'text',
+            'show'      => 'identity=2,3',
+            'tab'       => 2,
+        ),
+
+        'company_number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '社会信用代码',
+            'default'   => '',
+            'desc'      => '社会信用代码',
+            'match'     => 'option',
+            //'update'    => 'text',
             'show'		=> 'identity=2,3',
             'tab'		=> 2,
         ),

+ 1 - 1
module/scm_supplier/lib/Manage.php

@@ -18,7 +18,7 @@ class Manage
 		$where['goods_id'] = $goods_id;
 		$where['sku_id'] = $sku_id;
 		$where['supplier_id'] = Dever::input('update_supplier_id');
-		$info = Dever::db('scm_supplier/goods_sku')->getOne($where);
+		$info = Dever::db('scm_supplier/goods')->getOne($where);
 		if (!$info) {
 			$supplier = Dever::db('scm_supplier/info')->one($where['supplier_id']);
 			$goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);

+ 1 - 1
module/scm_supplier/lib/Set.php

@@ -64,7 +64,7 @@ class Set
         $data = array();
         $data['id'] = Dever::input('id', 1);
         $data['role'] = Dever::input('role');
-        $data['name'] = '销商';
+        $data['name'] = '销商';
         if ($data['role'] == 'servicer') {
             $data['name'] = '配送商';
         }