dever 3 gadi atpakaļ
vecāks
revīzija
11bf2cae00
42 mainītis faili ar 1065 papildinājumiem un 360 dzēšanām
  1. 206 32
      app/cash/lib/Set.php
  2. 12 2
      app/factory/admin/Order.php
  3. 6 0
      app/factory/admin/Stat.php
  4. 2 2
      app/factory/assets/pc/html/order.html
  5. 0 0
      app/factory/assets/pc/html/order_send.html
  6. 1 1
      app/factory/lib/Goods.php
  7. 2 3
      app/factory/lib/Order.php
  8. 39 10
      app/goods/database/info.php
  9. 19 8
      app/goods/database/info_sku.php
  10. 1 1
      app/goods/lib/Info.php
  11. 3 1
      app/goods/lib/Set.php
  12. 33 32
      app/goods/lib/Sku.php
  13. 264 21
      app/mshop/lib/Buy.php
  14. 124 13
      app/mshop/lib/Out.php
  15. 2 0
      app/mshop/src/Buy.php
  16. 8 0
      app/mshop/src/Data.php
  17. 31 65
      app/mshop/src/Goods.php
  18. 24 9
      app/shop/assets/pc/html/setGoods.html
  19. 4 15
      app/shop/database/buy_order_goods.php
  20. 1 1
      app/shop/database/goods.php
  21. 5 4
      app/shop/database/info.php
  22. 2 13
      app/shop/database/out_order_goods.php
  23. 2 13
      app/shop/database/sell_order_goods.php
  24. 13 11
      app/shop/lib/Info.php
  25. 15 24
      app/shop/lib/Refund.php
  26. 9 7
      app/shop/lib/Sell.php
  27. 46 26
      app/shop/lib/Set.php
  28. 81 0
      app/store/admin/Goods.php
  29. 13 4
      app/store/admin/Order.php
  30. 5 0
      app/store/admin/Out.php
  31. 7 1
      app/store/admin/Stat.php
  32. 1 1
      app/store/assets/pc/html/goods.html
  33. 1 1
      app/store/assets/pc/html/order.html
  34. 0 0
      app/store/assets/pc/html/order_send.html
  35. 1 1
      app/store/assets/pc/html/out.html
  36. 20 8
      app/store/assets/pc/html/setGoodsNum.html
  37. 1 1
      app/store/assets/pc/html/stat.html
  38. 1 1
      app/store/database/info.php
  39. 2 2
      app/store/lib/Goods.php
  40. 47 26
      app/store/lib/Set.php
  41. 1 0
      app/store/template/pc/goods.php
  42. 10 0
      main/database/config.php

+ 206 - 32
app/cash/lib/Set.php

@@ -121,11 +121,17 @@ class Set
         $html .= '<table class="layui-table"><tbody>';
 
         $html .= '<tr>
-          <td width="80">对账'.$name.'</td>
+          <td width="100">对账'.$name.'</td>
           <td>'.$this->table(false, array(array($other['name']))).'</td>
 
         </tr>';
 
+        $html .= '<tr>
+          <td width="80">对账时间</td>
+          <td>'.$this->table(false, array(array($this->statDate($info['type'], $info['day'])))).'</td>
+
+        </tr>';
+
         $html .= '<tr>
           <td width="80">对账周期</td>
           <td>'.$this->table(false, array(array($this->statTime($info['start'], $info['end'])))).'</td>
@@ -177,12 +183,12 @@ class Set
             $config['phone'] = '联系人:' . $other['truename'] . ',联系电话:' . $other['mobile'];
             $button[] = '<button class="layui-btn layui-btn-primary" onclick="showAlert(\''.$config['phone'].'\')">联系'.$name.'</button>';
 
-            $info['start'] = date('Y-m-d H:i:s', $info['start']);
-            $info['end'] = date('Y-m-d H:i:s', $info['end']);
-            $out = Dever::url('database.list_excel?project=cash&table=order&search_option_status=2&search_option_state=1&search_option_start_cdate=' . $info['start'] . '&search_option_end_cdate=' . $info['end'], 'manage');
+            $start = date('Y-m-d H:i:s', $info['start']);
+            $end = date('Y-m-d H:i:s', $info['end']);
+            $out = Dever::url('database.list_excel?project=cash&table=order&search_option_status=2&search_option_state=1&search_option_start_cdate=' . $start . '&search_option_end_cdate=' . $end, 'manage');
             
             $button[] = '<a class="layui-btn layui-btn-primary" href="'.$out.'">导出对账单</a>';
-        } else {
+        } elseif ($show == 2) {
             if ($info[$type . '_status'] == 1 && $show != 1) {
 
                 $url = Dever::url('lib/set.audit_other&id='.$id.'&type=' . $type, 'cash');
@@ -191,11 +197,10 @@ class Set
             $config = Dever::load('factory/admin/auth.config');
             $config['phone'] = '联系电话:' . $config['dz_phone'];
             $button[] = '<button class="layui-btn layui-btn-primary" onclick="showAlert(\''.$config['phone'].'\')">联系对账专员</button>';
-
-            $info['start'] = date('Y-m-d H:i:s', $info['start']);
-            $info['end'] = date('Y-m-d H:i:s', $info['end']);
             
-            $button[] = '<a class="layui-btn layui-btn-primary" onclick="print(\''.$info['id'].'\')">打印对账单</a>';
+            $print = Dever::url('admin/stat.print?id=' . $info['id'] . '&type=' . $type, $type);
+
+            $button[] = '<a class="layui-btn layui-btn-primary" href="'.$print.'" target="_blank">打印对账单</a>';
         }
         
         $html .= '<tr>
@@ -206,17 +211,25 @@ class Set
 
         $html .= '</tbody></table></div></div>';
 
-        $where['type'] = 1;
-        $where['type_id'] = $info[$type . '_id'];
+        $id = $info[$type . '_id'];
+        if ($type == 'shop') {
+            $where['type'] = 1;
+            $where['type_id'] = $id;
+        } elseif ($type == 'factory') {
+            $where['source_type'] = 3;
+            $where['source_id'] = $id;
+        } else {
+            $where['type'] = 2;
+            $where['type_id'] = $id;
+            //$where['source_type_or'] = 2;
+            //$where['source_id_or'] = $id;
+        }
         $where['status'] = 2;
-
-        $data = Dever::db('cash/order')->select_page($where);
+        $where['start'] = $info['start'];
+        $where['end'] = $info['end'];
+        $data = Dever::db('cash/order')->getAll($where);
         if ($data) {
-            $head = array('结算单号', '订货单号', '结算类型', '下单日期', '完成日期', '结算日期', '对账金额', '结算状态');
-
-            if ($type == 'store') {
-                $head[6] = '对账数量';
-            }
+            
             $body = array();
             $config = Dever::db('cash/order')->config;
             foreach ($data as $k => $v) {
@@ -226,27 +239,46 @@ class Set
                 if ($type == 'store') {
                     $cash = $v['num'];
                 } elseif ($type == 'factory') {
-                    $cash = $v['p_cash'];
+                    $cash = '¥' . round($v['p_cash'], 2);
                 } else {
-                    $cash = $v['cash'];
+                    $cash = '¥' . round($v['cash'], 2);
                 }
 
                 if ($show == 1) {
                     $url = Dever::url('project/database/list?project=shop&table=buy_order_goods&order_id='.$v['source_order_id'].'&page_type=1', 'manage');
                     $v['source_order_num'] = '<a href="'.$url.'" style="color:blue">'.$v['source_order_num'].'</a>';
+
+                    $head = array('结算单号', '订货单号', '结算类型', '下单日期', '完成日期', '结算日期', '对账金额', '结算状态');
+                    if ($type == 'store') {
+                        $head[6] = '对账数量';
+                    }
+
+                    $body[] = array
+                    (
+                        $v['order_num'],
+                        $v['source_order_num'],
+                        $config['config_jstype'][$v['jstype']],
+                        $cdate,
+                        $fdate,
+                        $operdate,
+                        $cash,
+                        '已入账'
+                    );
+                } else {
+                    $head = array('订货单号', '下单日期', '完成日期', '对账金额', '状态');
+                    if ($type == 'store') {
+                        $head[3] = '对账数量';
+                    }
+
+                    $body[] = array
+                    (
+                        $v['source_order_num'],
+                        $cdate,
+                        $fdate,
+                        $cash,
+                        '已入账'
+                    );
                 }
-                
-                $body[] = array
-                (
-                    $v['order_num'],
-                    $v['source_order_num'],
-                    $config['config_jstype'][$v['jstype']],
-                    $cdate,
-                    $fdate,
-                    $operdate,
-                    round($cash, 2),
-                    '已入账'
-                );
             }
 
 
@@ -295,4 +327,146 @@ class Set
         }
         return $html;
     }
+
+    # 打印订单单
+    public function printer($user)
+    {
+        $id = Dever::input('id');
+        if (!$id) {
+            return false;
+        }
+
+        $type = Dever::input('type', 'shop');
+        if ($type == 'shop') {
+            $name = '门店';
+        } elseif ($type == 'store') {
+            $name = '仓库';
+        } elseif ($type == 'factory') {
+            $name = '工厂';
+        }
+
+        $table = 'cash/' . $type;
+
+        $config = Dever::db($table)->config;
+
+        $info = Dever::db($table)->one($id);
+
+        $status = $config['config_status'][$info['status']];
+        $other_status = $config['config_status'][$info[$type . '_status']];
+
+        $other = Dever::db($type . '/info')->find($info[$type . '_id']);
+
+        $member = Dever::db($type  . '/member')->find($user['id']);
+
+        $factory_config = Dever::db('main/factory_config')->find();
+        $main_config = Dever::db('main/config')->find();
+
+        $pdf = Dever::load('pdf/lib/base')->init();
+
+        $pdf->hr('-', $other['name']);
+
+        $pdf->br()->font(20)->center('对账周期:' . $this->statTime($info['start'], $info['end']));
+        $pdf->font(10);
+        $pdf->br();
+
+        $pdf->br()->left('对账日期:' . $this->statDate($info['type'], $info['day']), 80)->left('制单人:' . $member['name'], 60)->left('制单时间:' . date('Y-m-d H:i'), 40);
+
+        $pdf->hr();
+
+        if ($type == 'store') {
+            $where['type'] = 2;
+            $where['type_id'] = $info[$type . '_id'];
+        } else {
+            $where['source_type'] = 3;
+            $where['source_id'] = $info[$type . '_id'];
+        }
+        
+        $where['status'] = 2;
+        $where['start'] = $info['start'];
+        $where['end'] = $info['end'];
+        $data = Dever::db('cash/order')->getAll($where);
+
+        $body = array();
+        $body_total = array();
+        $body_total['cash'] = 0;
+        $body_total['num'] = 0;
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $cdate = date('Y-m-d H:i', $v['cdate']);
+                $fdate = $v['fdate'] ? date('Y-m-d H:i', $v['fdate']) : '';
+                $operdate = $v['operdate'] ? date('Y-m-d H:i', $v['operdate']) : '';
+                if ($type == 'store') {
+                    $cash = $v['num'];
+                } elseif ($type == 'factory') {
+                    $cash = '¥' . $v['p_cash'];
+                } else {
+                    $cash = '¥' . $v['cash'];
+                }
+
+                $cash = round($cash, 2);
+
+                $body[] = array
+                (
+                    $v['source_order_num'],
+                    $cdate,
+                    $fdate,
+                    $cash,
+                    '已入账'
+                );
+
+                $body_total['cash'] += $cash;
+                $body_total['num'] += 1;
+            }
+        }
+
+        $head = array(array('订单号', 60), array('下单日期', 43), array('完成日期', 43), array('对账金额', 30), array('状态', 20));
+
+        if ($type == 'store') {
+            $head[3][0] = '对账数量';
+        }
+
+        if ($body) {
+            $pdf->br();
+            foreach ($head as $k => $v) {
+                $pdf->left($v[0], $v[1]);
+            }
+
+            foreach ($body as $k => $v) {
+                $pdf->br();
+                foreach ($head as $k1 => $v1) {
+                    $pdf->left($v[$k1], $v1[1]);
+                }
+            }
+            $pdf->br();
+            if ($type == 'store') {
+                $pdf->right('共'.$body_total['num'].'个订单,合计对账数量' . $body_total['cash'] . '个');
+            } else {
+                $pdf->right('共'.$body_total['num'].'个订单,合计对账金额¥' . $body_total['cash'] . '元');
+            }
+            
+            $pdf->hr();
+        }
+
+        $pdf->br(1);
+        //$pdf->SetY(-100);
+        
+        $pdf->right('如遇任何问题请致电客服');
+        $pdf->br();
+
+        $pdf->font(20);
+        $pdf->left($main_config['name'], 160);
+
+        $pdf->font(10);
+        $pdf->right('电话:' . $factory_config['phone'], 30);
+
+        $pdf->br();
+
+        $pdf->left($main_config['site'], 160);
+
+        $pdf->font(10);
+        $pdf->right($main_config['worktime'], 30);
+
+        $pdf->out('对账单');
+    }
 }

+ 12 - 2
app/factory/admin/Order.php

@@ -17,7 +17,7 @@ class Order extends Core
 		$data['order_num'] = Dever::db('shop/buy_order')->getOrderNum($where);
 
 		# 超时待处理订单:72小时
-		$where['end_o'] = time() + 72*3600;
+		$where['end_o'] = time() - 72*3600;
 		$data['cs_order_num'] = Dever::db('shop/buy_order')->getOrderNum($where);
 
 		return $data;
@@ -43,7 +43,10 @@ class Order extends Core
         		$button = '<a href="'.$view.'"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看详情</button></a>';
 
         		if ($v['status'] < 5) {
-        			$button .= '&nbsp;&nbsp;<a href="javascript:;" id="print_'.$v['id'].'" onclick="layer.alert(\'开发中\')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">打印备货单</button></a>';
+
+                    $print = Dever::url('admin/order.print?id=' . $v['id'] . '&type=1', 'factory');
+
+        			$button .= '&nbsp;&nbsp;<a href="'.$print.'" id="print_'.$v['id'].'" target="_blank"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">打印备货单</button></a>';
         		}
         		
         		if ($v['status'] == 3) {
@@ -145,4 +148,11 @@ class Order extends Core
 
     	return 'reload';
     }
+
+    # 打印订单单
+    public function print_api()
+    {
+        return Dever::load('mshop/lib/buy')->printer($this->user);
+    }
+
 }

+ 6 - 0
app/factory/admin/Stat.php

@@ -77,4 +77,10 @@ class Stat extends Core
 
     	return $data;
     }
+
+    # 打印订单单
+    public function print_api()
+    {
+        return Dever::load('cash/lib/set')->printer($this->user);
+    }
 }

+ 2 - 2
app/factory/assets/pc/html/order.html

@@ -23,7 +23,7 @@
 
           <div class="layui-form layui-card-header layuiadmin-card-header-auto">
             <div class="layui-form-item">
-              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="order_num" id="order_num" autocomplete="off" placeholder="订单编号"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder=">=订货时间" name="start" id="start" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder="<=订货时间" name="end" id="end" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="status" id="status"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" onclick="out($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">批量打印备货单</button></div></div></div></div>
+              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="order_num" id="order_num" autocomplete="off" placeholder="订单编号"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder=">=订货时间" name="start" id="start" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder="<=订货时间" name="end" id="end" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="status" id="status"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" onclick="out($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;display:none;">批量打印备货单</button></div></div></div></div>
             </div>
           </div>
         </div>
@@ -69,7 +69,7 @@
   });
 
   function out() {
-      layer.alert('开发中');
+      layer.alert('开发中1');
 
       return;
       var index = layer.confirm('确定进行此项操作吗?', function()

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
app/factory/assets/pc/html/order_send.html


+ 1 - 1
app/factory/lib/Goods.php

@@ -36,7 +36,7 @@ class Goods
                         (
                             'id' => $v['id'] . '-' . $data[$k]['sku_id'],
                             'name' => $v['name'] . '-' . $data[$k]['sku_name'],
-                            'price' => $data[$k]['p_price'] ? $data[$k]['p_price'] : 0,
+                            'price' => $v['p_price'] ? $v['p_price'] : 0,
                             'end' => true,
                         );
                     }

+ 2 - 3
app/factory/lib/Order.php

@@ -85,9 +85,8 @@ class Order
             $data['order_id'] = $id;
             $data['goods_id'] = $v['id'];
             $data['sku_id'] = $v['sku_id'];
-            $data['price'] = $v['price'] * $v['buy_num'];
-            $data['p_price'] = $v['p_price'] * $v['buy_num'];
-            $data['d_price'] = $v['price'];
+            $data['price'] = $v['price'];
+            $data['p_price'] = $v['p_price'];
             $data['num'] = $v['buy_num'];
 
             $state = Dever::db('shop/buy_order_goods')->insert($data);

+ 39 - 10
app/goods/database/info.php

@@ -10,6 +10,12 @@ $price_type = array
     4 => '组合商品',
 );
 
+$sell_type = array
+(
+    1 => '可售卖',
+    2 => '不可售卖',
+);
+
 $mode = array
 (
     1 => '自提',
@@ -118,13 +124,25 @@ $config = array
             'edit'        => true,
         ),
 
+        'sell_type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '售卖类型',
+            'default'   => '1',
+            'desc'      => '售卖类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $sell_type,
+            'control'   => 'sell_type',
+        ),
+
         'column_id'        => array
         (
             'type'      => 'varchar-8000',
-            'name'      => '栏目',
+            'name'      => '售卖栏目',
             'default'   => '',
-            'desc'      => '所属项目',
-            'match'     => 'is_string',
+            'desc'      => '售卖栏目',
+            'match'     => 'option',
             'update'    => 'checkbox',
             'option'    => $column,
             //'list'      => true,
@@ -133,9 +151,9 @@ $config = array
         'category'      => array
         (
             'type'      => 'varchar-500',
-            'name'      => '分类',
+            'name'      => '属性规格分类',
             'default'   => '',
-            'desc'      => '分类',
+            'desc'      => '属性规格分类',
             'match'     => 'is_string',
             'search'    => 'linkage',
             'update'    => 'linkage',
@@ -174,7 +192,7 @@ $config = array
         'tag_id'        => array
         (
             'type'      => 'varchar-800',
-            'name'      => '标签',
+            'name'      => '商品标签',
             'default'   => '',
             'desc'      => '标签',
             'match'     => 'option',
@@ -230,7 +248,7 @@ $config = array
 
         'price'     => array
         (
-            'type'      => 'decimal-10,2',
+            'type'      => 'varchar-100',
             'name'      => '销售价',
             'default'   => '',
             'desc'      => '销售价',
@@ -241,7 +259,7 @@ $config = array
 
         's_price'       => array
         (
-            'type'      => 'decimal-10,2',
+            'type'      => 'varchar-100',
             'name'      => '市场价',
             'default'   => '',
             'desc'      => '市场价',
@@ -252,7 +270,7 @@ $config = array
 
         'f_price'       => array
         (
-            'type'      => 'decimal-10,2',
+            'type'      => 'varchar-100',
             'name'      => '采购价',
             'default'   => '',
             'desc'      => '采购价',
@@ -261,6 +279,17 @@ $config = array
             'show'      => 'price_type=1',
         ),
 
+        'min'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '起购数',
+            'default'   => '1',
+            'desc'      => '起购数',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+            //'list'      => true,
+        ),
+
         'goods'       => array
         (
             'type'      => 'text-1000',
@@ -480,7 +509,7 @@ $config = array
 
             'fast_list' => array('价格设置', '"info_sku&project=goods&goods_id={id}&page_type=1"', '{price_type} > 0'),
             'br1' => array('<br />'),
-            'delete' => '删除',
+            //'delete' => '删除',
         ),
     ),
 

+ 19 - 8
app/goods/database/info_sku.php

@@ -68,7 +68,7 @@ $config = array
 
         'price'     => array
         (
-            'type'      => 'decimal-10,2',
+            'type'      => 'varchar-100',
             'name'      => '销售价',
             'default'   => '',
             'desc'      => '销售价',
@@ -79,7 +79,7 @@ $config = array
 
         's_price'       => array
         (
-            'type'      => 'decimal-10,2',
+            'type'      => 'varchar-100',
             'name'      => '市场价',
             'default'   => '',
             'desc'      => '市场价',
@@ -90,7 +90,7 @@ $config = array
 
         'f_price'       => array
         (
-            'type'      => 'decimal-10,2',
+            'type'      => 'varchar-100',
             'name'      => '采购价',
             'default'   => '',
             'desc'      => '采购价',
@@ -99,6 +99,17 @@ $config = array
             'list'      => true,
         ),
 
+        'min'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '起购数',
+            'default'   => '1',
+            'desc'      => '起购数',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
         'num'       => array
         (
             'type'      => 'int-11',
@@ -214,7 +225,7 @@ $config = array
             ),
             'type' => 'all',
             'order' => array('id' => 'desc'),
-            'col' => 'id,info_id,`key`,price,s_price,type',
+            'col' => 'id,info_id,`key`,price,s_price,type,min',
         ),
 
         # 列表
@@ -228,7 +239,7 @@ $config = array
             ),
             'type' => 'all',
             'order' => array('id' => 'desc'),
-            'col' => 'id,info_id,`key`,price,s_price,f_price|key',
+            'col' => 'id,info_id,`key`,price,s_price,f_price,min|key',
         ),
 
         # 获取单条数据
@@ -241,7 +252,7 @@ $config = array
                 'state' => 1,
             ),
             'type' => 'one',
-            'col' => 'id,info_id,price,s_price,f_price',
+            'col' => 'id,info_id,price,s_price,f_price,min',
         ),
 
         'getMinOne' => array
@@ -254,7 +265,7 @@ $config = array
             ),
             'type' => 'one',
             'order' => array('price' => 'asc', 'id' => 'desc'),
-            'col' => 'id,info_id,price,s_price',
+            'col' => 'id,info_id,price,s_price,min',
         ),
 
         'getMaxOne' => array
@@ -267,7 +278,7 @@ $config = array
             ),
             'type' => 'one',
             'order' => array('price' => 'desc', 'id' => 'desc'),
-            'col' => 'id,info_id,price,s_price',
+            'col' => 'id,info_id,price,s_price,min',
         ),
 
         # 更新售出量

+ 1 - 1
app/goods/lib/Info.php

@@ -287,7 +287,7 @@ class Info
                         $info['s_price'] = $sku['s_price'];
                     }
 
-                    //$info['num'] = $sku['num'];
+                    $info['min'] = $sku['min'];
                     //$info['attr_json'] = $sku['attr'];
                     $info['attr'] = Dever::json_decode($sku['attr']);
 

+ 3 - 1
app/goods/lib/Set.php

@@ -12,7 +12,7 @@ class Set
         $where['status'] = 1;
 
         if ($type != 'factory_id') {
-            $where['price_type'] = '1,2,3';
+            //$where['price_type'] = '1,2,3';
         }
         $data = Dever::db('goods/info')->getData($where);
 
@@ -27,6 +27,7 @@ class Set
                     $result[$k]['id'] = $v['id'];
                     $result[$k]['name'] = $v['name'];
                     $result[$k]['price'] = $v['price'];
+                    $result[$k]['price_type'] = $v['price_type'];
                     $result[$k]['select'] = 2;
                     if ($type == 'factory_id') {
                         if ($other) {
@@ -69,6 +70,7 @@ class Set
                                 'id' => $v['id'] . '-' . $v1['id'],
                                 'name' => $name,
                                 'price' => $v1['price'] ? $v1['price'] : 0,
+                                'price_type' => $v['price_type'],
                                 'end' => true,
                             );
 

+ 33 - 32
app/goods/lib/Sku.php

@@ -12,6 +12,7 @@ class Sku
         's_price' => '市场价',
         'f_price' => '采购价',
         'price' => '销售价',
+        'min' => '起购数',
     );
 
     # 主要价格字段
@@ -336,6 +337,7 @@ class Sku
         }
 
         $input = '';
+        $sku_value = array();
         if ($other) {
             $other_col = $other . '_id';
             $sku_value = Dever::db($other . '/goods_sku')->getData(array('goods_id' => $info['id'], $other_col => $other_id));
@@ -431,12 +433,7 @@ class Sku
                 if (!$update && strstr($v1, '^')) {
                     continue;
                 } 
-                $value = '';
-                if (isset($sku_value[-1]) && isset($sku_value[-1][$k1])) {
-                    $value = $sku_value[-1][$k1];
-                } elseif (isset($sku[-1]) && isset($sku[-1][$k1])) {
-                    $value = $sku[-1][$k1];
-                }
+                $value = $this->getValue($k1, -1, $sku_value, $sku);
                 
                 if ($update) {
                     if (strstr($v1, '|')) {
@@ -487,14 +484,7 @@ class Sku
                     if (!$update && strstr($v1, '^')) {
                         continue;
                     } 
-                    $value = '';
-                    if (isset($sku[$key])) {
-                        if (isset($sku_value[$sku[$key]['id']][$k1])) {
-                            $value = $sku_value[$sku[$key]['id']][$k1];
-                        } elseif (isset($sku[$key][$k1])) {
-                            $value = $sku[$key][$k1];
-                        }
-                    }
+                    $value = $this->getValue($k1, $key, $sku_value, $sku);
                     
                     if ($update) {
                         if (strstr($v1, '|')) {
@@ -551,14 +541,7 @@ class Sku
                     if (!$update && strstr($v1, '^')) {
                         continue;
                     } 
-                    $value = '';
-                    if (isset($sku[$key])) {
-                        if (isset($sku_value[$sku[$key]['id']][$k1])) {
-                            $value = $sku_value[$sku[$key]['id']][$k1];
-                        } elseif (isset($sku[$key][$k1])) {
-                            $value = $sku[$key][$k1];
-                        }
-                    }
+                    $value = $this->getValue($k1, $key, $sku_value, $sku);
                     
                     if ($update) {
                         if (strstr($v1, '|')) {
@@ -619,15 +602,7 @@ class Sku
                     if (!$update && strstr($v1, '^')) {
                         continue;
                     } 
-                    $value = '';
-                    if (isset($sku[$key])) {
-                        if (isset($sku_value[$sku[$key]['id']][$k1])) {
-                            $value = $sku_value[$sku[$key]['id']][$k1];
-                        } elseif (isset($sku[$key][$k1])) {
-                            $value = $sku[$key][$k1];
-                        }
-                    }
-                    
+                    $value = $this->getValue($k1, $key, $sku_value, $sku);
                     if ($update) {
                         if (strstr($v1, '|')) {
                             $v1 = str_replace('|', '', $v1);
@@ -658,7 +633,33 @@ class Sku
     private function create_table($head, $body)
     {
         $html = '<table class="layui-table">';
+    }
 
-
+    private function getValue($k1, $key, $sku_value, $sku)
+    {
+        $value = '';
+        if ($k1 == 'min') {
+            $value = 0;
+        } else {
+            $value = 0;
+        }
+        
+        if ($key == -1) {
+            if (isset($sku_value[-1]) && isset($sku_value[-1][$k1])) {
+                $value = $sku_value[-1][$k1];
+            } elseif (isset($sku[-1]) && isset($sku[-1][$k1])) {
+                $value = $sku[-1][$k1];
+            }
+        } else {
+            if (isset($sku[$key])) {
+                if (isset($sku_value[$sku[$key]['id']][$k1])) {
+                    $value = $sku_value[$sku[$key]['id']][$k1];
+                } elseif (isset($sku[$key][$k1])) {
+                    $value = $sku[$key][$k1];
+                }
+            }
+        }
+        
+        return $value;       
     }
 }

+ 264 - 21
app/mshop/lib/Buy.php

@@ -269,8 +269,7 @@ class Buy
             $data['order_id'] = $id;
             $data['goods_id'] = $v['id'];
             $data['sku_id'] = $v['sku_id'];
-            $data['price'] = $v['price'] * $v['buy_num'];
-            $data['d_price'] = $v['price'];
+            $data['price'] = $v['price'];
             $data['num'] = $v['buy_num'];
 
             Dever::db('shop/buy_order_goods')->insert($data);
@@ -556,9 +555,9 @@ class Buy
 
         $cdate = date('Y-m-d H:i', $info['cdate']);
         if ($info['operdate']) {
-            $opertime = date('Y-m-d H:i', $info['operdate']);
+            $operdate = date('Y-m-d H:i', $info['operdate']);
         } else {
-            $opertime = '';
+            $operdate = '';
         }
 
         if ($info['fdate']) {
@@ -595,9 +594,9 @@ class Buy
         }
 
         if ($type == 1) {
-            $time = array('下单时间:' . $cdate, '订货时间:' . $opertime);
+            $time = array('下单时间:' . $cdate, '订货时间:' . $operdate);
         } else {
-            $time = array('订货时间:' . $opertime);
+            $time = array('订货时间:' . $operdate);
         }
 
         if ($fdate) {
@@ -652,7 +651,8 @@ class Buy
             $config = Dever::load('factory/admin/auth.config');
             $button = array();
             if ($info['status'] < 5) {
-                $button[] = '<button class="layui-btn layui-btn-primary" onclick="print(\''.$info['id'].'\')">打印货单</button>';
+                $print = Dever::url('admin/order.print?id=' . $info['id'] . '&type=1', 'factory');
+                $button[] = '<a class="layui-btn layui-btn-primary" href="'.$print.'" target="_blank">打印货单</a>';
             }
             if ($info['status'] == 3) {
                 $send = Dever::url('order_send?id=' . $info['id'], 'factory');
@@ -670,8 +670,13 @@ class Buy
         } elseif ($type == 3) {
             $config = Dever::load('factory/admin/auth.config');
             $button = array();
-            $button[] = '<button class="layui-btn layui-btn-primary" onclick="print(\''.$info['id'].'\')">打印订单</button>';
-            if ($info['status'] == 4) {
+            $print = Dever::url('admin/order.print?id=' . $info['id'] . '&type=2', 'store');
+            $button[] = '<a class="layui-btn layui-btn-primary" href="'.$print.'" target="_blank">打印货单</a>';
+            if ($info['status'] == 3) {
+                $send = Dever::url('order_send?id=' . $info['id'] . '&type=2', 'store');
+                $button[] = '<button class="layui-btn layui-btn-primary" onclick="fastEdit($(this), \''.$send.'\', \'配送发货\', \'\', 1)">配送发货</button>';
+            }
+            if ($info['status'] == 4 && $info['type'] == 2) {
                 $url = Dever::url('admin/factory_order.action?order_id='.$info['id'], 'store');
                 $button[] = '<button class="layui-btn layui-btn-primary" onclick="load(\''.$url.'\')">确认收货</button>';
             }
@@ -753,7 +758,6 @@ class Buy
         }
 
         
-
         $body = array();
         $body_total = array();
         $body_total['price'] = 0;
@@ -844,7 +848,7 @@ class Buy
 
         if ($body) {
 
-            $head = array('名称', '金额', '数量', '状态');
+            $head = array('名称', '单价', '数量', '状态');
 
             $d = array
             (
@@ -866,7 +870,7 @@ class Buy
 
         if ($refund_body) {
 
-            $head = array('名称', '金额', '数量', '状态');
+            $head = array('名称', '单价', '数量', '状态');
 
             $d = array
             (
@@ -1166,7 +1170,7 @@ class Buy
             if ($sku) {
                 if ($goods['num'] <= $sku['total']) {
                     # 如果库存符合,直接下单即可,生成仓库订单
-                    $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 2, $where['store_id'], $goods['price'], $goods['price'], $goods['d_price'], $goods['num'], $where['goods_id'], $where['sku_id']);
+                    $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 2, $where['store_id'], $goods['price'], $goods['price'], $goods['num'], $where['goods_id'], $where['sku_id']);
                     if ($state) {
                         $type_id[] = $where['store_id'];
                         $id[] = $state;
@@ -1177,7 +1181,7 @@ class Buy
                     # 如果库存不够,从这个仓库扣下一部分,剩余的从另外仓库处理
                     $goods['num'] = $goods['num'] - $sku['total'];
                     # 生成仓库订单
-                    $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 2, $where['store_id'], $goods['price'], $goods['price'], $goods['d_price'], $sku['total'], $where['goods_id'], $where['sku_id']);
+                    $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 2, $where['store_id'], $goods['price'], $goods['price'], $sku['total'], $where['goods_id'], $where['sku_id']);
                     if (!$state) {
                         $goods['num'] = $goods['num'] + $sku['total'];
                     } else {
@@ -1213,7 +1217,7 @@ class Buy
             $sku = Dever::db('factory/goods_sku')->getOne($where);
 
             if ($sku && $sku['p_price'] > 0) {
-                $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 3, $where['factory_id'], $goods['price'], $sku['p_price'], $goods['d_price'], $goods['num'], $where['goods_id'], $where['sku_id']);
+                $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 3, $where['factory_id'], $goods['price'], $sku['p_price'], $goods['num'], $where['goods_id'], $where['sku_id']);
                 if ($state) {
                     $type_id[] = $where['factory_id'];
                     $id[] = $state;
@@ -1244,7 +1248,7 @@ class Buy
     }
 
     # 生成拆单的订单
-    private function createOrder($order_id, $order_num, $type, $type_id, $source_type, $source_id, $price, $p_price, $d_price, $num, $goods_id, $sku_id)
+    private function createOrder($order_id, $order_num, $type, $type_id, $source_type, $source_id, $price, $p_price, $num, $goods_id, $sku_id)
     {
         $where['parent_order_id'] = $order_id;
         $where['type'] = $type;
@@ -1261,16 +1265,16 @@ class Buy
             $data['order_num'] = $order_num;
             $data['operdate'] = time();
             $data['status'] = 3;
-            $data['price'] = $price;
-            $data['p_price'] = $p_price;
+            $data['price'] = $price * $num;
+            $data['p_price'] = $p_price * $num;
             $data['num'] = $num;
             $id = $state = Dever::db('shop/buy_order')->insert($data);
         } else {
             $id = $info['id'];
 
             $data['where_id'] = $id;
-            $data['price'] = $info['price'] + $price;
-            $data['p_price'] = $info['p_price'] + $p_price;
+            $data['price'] = $info['price'] + ($price * $num);
+            $data['p_price'] = $info['p_price'] + ($p_price * $num);
             $data['num'] = $info['num'] + $num;
             $state = Dever::db('shop/buy_order')->update($data);
         }
@@ -1282,7 +1286,6 @@ class Buy
                 $goods['goods_id'] = $goods_id;
                 $goods['sku_id'] = $sku_id;
                 $goods['price'] = $price;
-                $goods['d_price'] = $d_price;
                 $goods['p_price'] = $p_price;
                 $goods['num'] = $num;
                 Dever::db('shop/buy_order_goods')->insert($goods);
@@ -1326,4 +1329,244 @@ class Buy
             return $state;
         }
     }
+
+    # 打印订单单
+    public function printer($user)
+    {
+        $id = Dever::input('id');
+        $type = Dever::input('type', 1);
+
+        $factory_config = Dever::db('main/factory_config')->find();
+        $main_config = Dever::db('main/config')->find();
+
+        $config = Dever::db('shop/buy_order')->config;
+
+        $info = Dever::db('shop/buy_order')->one($id);
+
+        $source_info = Dever::db('factory/info')->find($info['source_id']);
+        if ($type == 2) {
+            # 仓库
+            $member = Dever::db('store/member')->find($user['id']);
+            $name = '仓库名称';
+        } else {
+            # 工厂
+            $member = Dever::db('factory/member')->find($user['id']);
+            $name = '工厂名称';
+        }
+
+        if ($info['type'] == 1) {
+            $type_info = Dever::db('shop/info')->find($info['type_id']);
+        } elseif ($info['type'] == 2) {
+            $type_info = Dever::db('store/info')->find($info['type_id']);
+        } elseif ($info['type'] == 3) {
+            $type_info = Dever::db('store/info')->find($info['type_id']);
+        }
+
+        $cdate = date('Y-m-d H:i', $info['cdate']);
+        if ($info['operdate']) {
+            $operdate = date('Y-m-d H:i', $info['operdate']);
+        } else {
+            $operdate = '';
+        }
+
+        if ($info['fdate']) {
+            $fdate = date('Y-m-d H:i', $info['fdate']);
+        } else {
+            $fdate = '';
+        }
+
+        $status = $config['status'][$info['status']];
+
+        $info['ps_info'] = Dever::db('shop/buy_order_ps')->find(array('order_id' => $info['id']));
+        if ($info['ps_info']) {
+            $info['ps_info']['service_name'] = '供应商自送';
+            $info['ps_info']['cdate'] = date('Y-m-d H:i', $info['ps_info']['cdate']);
+            if ($info['ps_info']['ydate']) {
+                $info['ps_info']['ydate'] = date('Y-m-d H:i', $info['ps_info']['ydate']);
+            } else {
+                $info['ps_info']['ydate'] = '无';
+            }
+
+            $ps_status = Dever::db('shop/buy_order_ps')->config['status'];
+            $info['ps_info']['status_name'] = $status[$info['ps_info']['status']];
+            
+            if ($info['ps_info']['service_id'] > 0) {
+                //暂时还没有
+                $service = Dever::db('shop/service')->find($info['ps_info']['service_id']);
+                $info['ps_info']['service_name'] = $service['name'];
+            }
+
+            $info['ps_info']['order_num'] = str_replace("\r\n", ',', $info['ps_info']['order_num']);
+        }
+
+        $pdf = Dever::load('pdf/lib/base')->init();
+
+        $pdf->hr('-', $main_config['name']);
+
+        $pdf->br()->font(20)->center('订货单号:' . $info['order_num']);
+        $pdf->font(10);
+        $pdf->br();
+
+        $pdf->br()->left($name . ':' . $type_info['name'], 80)->left('制单人:' . $member['name'], 60)->left('制单时间:' . date('Y-m-d H:i'), 40);
+
+        $pdf->hr();
+
+        if ($type == 2 && $info['type'] == 2) {
+            $pdf->br()->left('订单状态:' . $status, 140)->left('订货时间:' . $operdate, 40);
+
+            $pdf->hr();
+
+            $pdf->br()->left('发货供应商:' . $source_info['name'], 140)->left('发货时间:' . $info['ps_info']['cdate'], 40);
+
+            if ($info['ps_info']) {
+                $pdf->br()->left('物流信息:' . $info['ps_info']['service_name'] . '     物流单号:' . $info['ps_info']['order_num'], 140)->left('确认收货时间:' . $info['ps_info']['ydate'], 40);
+            }
+
+            $pdf->hr();
+
+        } else {
+            $pdf->br()->left('订单状态:' . $status, 80)->left('订货人:' . $type_info['truename'], 60)->left('订货时间:' . $operdate, 40);
+
+            $pdf->hr();
+
+            $pdf->br()->left('配送至:' . $type_info['name'], 150)->right('收件人联系方式:' . $type_info['truename'] . ',' . $type_info['mobile'], 40);
+
+            $pdf->left('配送地址:' . $type_info['address']);
+
+            $pdf->hr();
+
+            if ($info['ps_info']) {
+
+                $pdf->br()->left('发货时间:' . $info['ps_info']['cdate'], 80)->left('配货员::' . $info['ps_info']['phy'], 70)->left('打包员:' . $info['ps_info']['dby'], 40);
+
+                $pdf->br()->left('包裹重量:' . $info['ps_info']['zl'] . '克', 80)->left('包裹体积:' . $info['ps_info']['tj'] . '立方厘米', 70)->left('包裹数量:' . $info['ps_info']['num'], 40);
+
+                $pdf->br()->left('物流信息:' . $info['ps_info']['service_name'], 40);
+
+                if ($info['ps_info']['order_num']) {
+                    $pdf->left('物流单号:' . $info['ps_info']['order_num'], 70);
+                }
+
+                $pdf->left('到货确认时间:' . $info['ps_info']['ydate']);
+
+                $pdf->hr();
+            }
+        }
+
+        $body = array();
+        $body_total = array();
+        $body_total['price'] = 0;
+        $body_total['num'] = 0;
+        $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $info['id']));
+        $goods_status = Dever::db('shop/buy_order_goods')->config['status'];
+
+        $refund_body = array();
+        $refund_body_total = array();
+        $refund_body_total['price'] = 0;
+        $refund_body_total['num'] = 0;
+        foreach ($goods as $k => $v) {
+            if ($type == 1) {
+                $v['price'] = $v['p_price'];
+            }
+            $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
+            $status = $goods_status[$v['status']];
+
+            $tk = Dever::db('shop/buy_order_refund')->find(array('order_id' => $info['id'], 'order_goods_id' => $v['id'], 'type' => 2));
+
+            if (isset($goods_info['sku'])) {
+                $sku = $goods_info['sku']['string'];
+            } else {
+                $sku = '无';
+            }
+
+            $d = array
+            (
+                $goods_info['id'],
+                $goods_info['name'],
+                $sku,
+                $v['price'],
+                'x ' . $v['num'],
+            );
+            if ($type == 2) {
+                unset($d[3]);
+            }
+            if ($tk && $v['status'] == 3 && $tk['status'] != 3) {
+
+                $refund_body[] = $d;
+                $refund_body_total['price'] += $v['price'];
+                $refund_body_total['num'] += $v['num'];
+            } else {
+                $body[] = $d;
+                $body_total['price'] += $v['price'];
+                $body_total['num'] += $v['num'];
+            }
+        }
+
+        $head = array(array('商品编号', 40), array('商品名称', 60), array('商品属性', 40), array('单价', 40), array('数量', 20));
+        if ($type == 2) {
+            unset($head[3]);
+            $head[1][1] = 70;
+            $head[2][1] = 60;
+        }
+        if ($body) {
+            $pdf->center('订单商品');
+            $pdf->br();
+            foreach ($head as $k => $v) {
+                $pdf->left($v[0], $v[1]);
+            }
+
+            foreach ($body as $k => $v) {
+                $pdf->br();
+                foreach ($head as $k1 => $v1) {
+                    $pdf->left($v[$k1], $v1[1]);
+                }
+            }
+            $pdf->br();
+            $pdf->right('共'.$body_total['num'].'件商品,合计金额¥' . $body_total['price'] . '元');
+            $pdf->hr();
+        }
+
+        if ($refund_body) {
+            $pdf->center('缺货与报损商品');
+            $pdf->br();
+            foreach ($head as $k => $v) {
+                $pdf->left($v[0], $v[1]);
+            }
+
+            foreach ($refund_body as $k => $v) {
+                $pdf->br();
+                foreach ($head as $k1 => $v1) {
+                    $pdf->left($v[$k1], $v1[1]);
+                }
+            }
+            $pdf->br();
+            if ($type == 2) {
+                $pdf->right('共'.$body_total['num'].'件商品');
+            } else {
+                $pdf->right('共'.$body_total['num'].'件商品,合计金额¥' . $body_total['price'] . '元');
+            }
+            
+            $pdf->hr();
+            
+        }
+        $pdf->br(1);
+        
+        $pdf->right('如遇任何问题请致电客服');
+        $pdf->br();
+
+        $pdf->font(20);
+        $pdf->left($main_config['name'], 160);
+
+        $pdf->font(10);
+        $pdf->right('电话:' . $factory_config['phone'], 30);
+
+        $pdf->br();
+
+        $pdf->left($main_config['site'], 160);
+
+        $pdf->font(10);
+        $pdf->right($main_config['worktime'], 30);
+
+        $pdf->out('订货单');
+    }
 }

+ 124 - 13
app/mshop/lib/Out.php

@@ -124,8 +124,7 @@ class Out
                 $data['order_id'] = $id;
                 $data['goods_id'] = $v['id'];
                 $data['sku_id'] = $v['sku_id'];
-                $data['price'] = $v['price'] * $v['buy_num'];
-                $data['d_price'] = $v['price'];
+                $data['price'] = $v['price'];
                 $data['num'] = $v['buy_num'];
 
                 $state = Dever::db('shop/out_order_goods')->insert($data);
@@ -293,7 +292,8 @@ class Out
                 $url = Dever::url('admin/out.cancel?order_id='.$info['id'], 'store');
                 $button[] = '&nbsp;&nbsp;<a href="javascript:;" onclick="load(\''.$url.'\')"><button type="button" class="layui-btn layui-btn-primary">取消</button></a>';
             }
-            $button[] = '<button class="layui-btn layui-btn-primary" onclick="print(\''.$info['id'].'\')">打印出库单</button>';
+            $print = Dever::url('admin/out.print?id=' . $info['id'] . '&type=2', 'store');
+            $button[] = '<a class="layui-btn layui-btn-primary" href="'.$print.'" target="_blank">打印出库单</a>';
 
             $config['phone'] = '您的专属客服:' . $config['kf_name'] . ',联系电话:' . $config['phone'];
             $button[] = '<button class="layui-btn layui-btn-primary" onclick="showAlert(\''.$config['phone'].'\')">联系平台</button>';
@@ -322,23 +322,20 @@ class Out
         $goods = Dever::db('shop/out_order_goods')->select(array('order_id' => $info['id']));
         $goods_status = Dever::db('shop/out_order_goods')->config['status'];
 
-        $refund_body = array();
-        $refund_body_total = array();
-        $refund_body_total['price'] = 0;
-        $refund_body_total['num'] = 0;
         foreach ($goods as $k => $v) {
             $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
             $status = $goods_status[$v['status']];
 
             if (isset($goods_info['sku'])) {
-                $sku = '[' . $goods_info['sku']['string'] . ']';
+                $sku = $goods_info['sku']['string'];
             } else {
-                $sku = '';
+                $sku = '';
             }
 
             $d = array
             (
-                $goods_info['name'] . ' ' . $sku,
+                $goods_info['name'],
+                $sku,
                 $v['price'],
                 $v['num'],
             );
@@ -352,7 +349,7 @@ class Out
 
         if ($body) {
 
-            $head = array('名称', '金额', '数量');
+            $head = array('商品名称', '商品属性', '商品单价', '商品数量');
 
             $d = array
             (
@@ -362,8 +359,8 @@ class Out
             );
 
             if ($type == 2) {
-                unset($head[1]);
-                unset($d[1]);
+                unset($head[2]);
+                unset($d[2]);
             }
             $body[] = $d;
 
@@ -416,4 +413,118 @@ class Out
         }
         return $html;
     }
+
+    public function printer($user)
+    {
+        $id = Dever::input('id');
+
+        $type = Dever::input('type', 2);
+
+        $factory_config = Dever::db('main/factory_config')->find();
+        $main_config = Dever::db('main/config')->find();
+        $config = Dever::db('main/config')->find();
+
+        $config = Dever::db('shop/out_order')->config;
+
+        $info = Dever::db('shop/out_order')->one($id);
+
+        if ($info['type'] == 1) {
+            $type_info = Dever::db('shop/info')->find($info['type_id']);
+            $member = Dever::db('shop/member')->find($info['member_id']);
+        } elseif ($info['type'] == 2) {
+            $type_info = Dever::db('store/info')->find($info['type_id']);
+            $member = Dever::db('store/member')->find($info['member_id']);
+        }
+
+        $status = $config['config_status'][$info['status']];
+
+        $out_type = $config['config_type'][$info['out_type']];
+
+        $cdate = date('Y-m-d H:i', $info['cdate']);
+
+        $pdf = Dever::load('pdf/lib/base')->init();
+
+        $pdf->hr('-', $main_config['name']);
+
+        $pdf->br()->font(20)->center('出库单号:' . $info['order_num']);
+        $pdf->font(10);
+        $pdf->br(2);
+
+        $pdf->br()->left('仓库名称:' . $type_info['name'], 80)->left('制单人:' . $user['name'], 60)->left('制单时间:' . date('Y-m-d H:i'), 40);
+
+        $pdf->hr();
+
+        $pdf->br()->left('出库单状态:' . $status, 140)->left('出库填单时间:' . $cdate, 40);
+
+        $pdf->left('出库类别:' . $out_type);
+
+        $pdf->left('原因备注:' . $info['info']);
+
+        $pdf->hr();
+
+        $head = array(array('商品编号', 40), array('商品名称', 70), array('商品属性', 60), array('出库数量', 20));
+
+        $data = Dever::db('shop/out_order_goods')->select(array('order_id' => $info['id']));
+
+        if ($data) {
+            $body = array();
+            $body_total = array();
+            $body_total['num'] = 0;
+
+            foreach ($data 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 = '';
+                }
+
+                $body[] = array
+                (
+                    $goods_info['id'],
+                    $goods_info['name'],
+                    $sku,
+                    'x ' . $v['num'],
+                );
+
+                $body_total['num'] += $v['num'];
+            }
+
+            $pdf->br();
+            foreach ($head as $k => $v) {
+                $pdf->left($v[0], $v[1]);
+            }
+
+            foreach ($body as $k => $v) {
+                $pdf->br();
+                foreach ($head as $k1 => $v1) {
+                    $pdf->left($v[$k1], $v1[1]);
+                }
+            }
+            $pdf->br();
+            $pdf->right('共'.$body_total['num'].'件商品');
+            $pdf->hr();
+        }
+
+        $pdf->br(1);
+        
+        $pdf->right('如遇任何问题请致电客服');
+        $pdf->br();
+
+        $pdf->font(20);
+        $pdf->left($main_config['name'], 160);
+
+        $pdf->font(10);
+        $pdf->right('电话:' . $factory_config['phone'], 30);
+
+        $pdf->br();
+
+        $pdf->left($main_config['site'], 160);
+
+        $pdf->font(10);
+        $pdf->right($main_config['worktime'], 30);
+
+        $pdf->out('库存清单');
+    }
 }

+ 2 - 0
app/mshop/src/Buy.php

@@ -10,6 +10,8 @@ class Buy extends Core
     # 获取所有商品列表
     public function getGoods()
     {
+
+        return Dever::load('mshop/out')->getGoods();
         $where = array();
 
         $name = Dever::input('name');

+ 8 - 0
app/mshop/src/Data.php

@@ -143,6 +143,14 @@ class Data extends Core
         }
     }
 
+    # 取消订单
+    public function order_cancel_commit()
+    {
+        $order_id = Dever::input('order_id');
+
+        return Dever::load('shop/lib/sell')->set(2, 2)->cancel($this->shop_id, $order_id);
+    }
+
     # 获取订单退款记录
     public function order_tui_log()
     {

+ 31 - 65
app/mshop/src/Goods.php

@@ -28,87 +28,53 @@ class Goods extends Core
     # 下单pdf
     public function pdf()
     {
-        Dever::apply('fpdf/chinese', 'pdf');
-        $pdf = new \PDF_Chinese('P','mm','A4');
-        $pdf->AddGBFont();
-        $pdf->Open();
-        $pdf->AddPage();
-        $pdf->SetFont('GB', '', 10);
-        $pdf->Cell(180, 8, $this->convert('------------------------------------------------------------------厨人易料------------------------------------------------------------------'), 0, 0);
-        $pdf->Ln(20);
-
-        $pdf->SetFont('GB', '', 20);
-        $pdf->Cell(0, 8,  $this->convert("库存清单"), 0, 0, 'C');
-        $pdf->Ln();
-        $pdf->Ln();
-        $pdf->Ln();
-        $pdf->SetFont('GB', '', 10);
-        $pdf->Cell(0, 8,  $this->convert("门店名称:" . $this->shop['name']), 0, 0);
-
-        $pdf->Ln();
-        $pdf->Cell(0, 8,  $this->convert("制单人:" . $this->user['name']), 0, 0);
-
-        $pdf->Ln();
-        $pdf->Cell(0, 8,  $this->convert("制单时间:" . date('Y-m-d H:i:s')), 0, 0);
-
-        $pdf->Ln();
-        $pdf->Cell(0, 8,  $this->convert("----------------------------------------------------------------------------------------------------------------------------------------------"), 0, 0);
-
-        $pdf->Ln();
-        $pdf->Cell(150, 8,  $this->convert("商品名称"), 0, 0);
-        $pdf->Cell(40, 8,  $this->convert("数量"), 0, 0, 'R');
-
+        $manage_config = Dever::db('main/manage_config')->find();
+        $sell_config = Dever::db('main/sell_config')->find();
+        $config = Dever::db('main/config')->find();
         $data = Dever::load('shop/lib/info')->getGoodsSku($this->shop_id);
 
+
+        $pdf = Dever::load('pdf/lib/base')->init();
+
+        $pdf->hr('-', $config['name']);
+
+        $pdf->br()->font(20)->center('库存清单');
+        $pdf->font(10);
+        $pdf->br(2);
+        $pdf->left('门店名称:' . $this->shop['name']);
+        $pdf->left('制单人:' . $this->user['name']);
+        $pdf->left('制单时间:' . date('Y-m-d H:i:s'));
+
+        $pdf->hr();
+
+        $pdf->br()->left('商品名称', 150)->right('数量', 40);
+
         if ($data) {
             foreach ($data as $k => $v) {
                 if (isset($v['price_array'])) {
-                    $pdf->Ln();
-                    $pdf->Cell(150, 8,  $this->convert($v['name']), 0, 0);
+                    $pdf->br()->left($v['name'], 150);
                     foreach ($v['price_array'] as $k1 => $v1) {
-                        $pdf->Ln();
-                        $pdf->Cell(150, 8,  $this->convert('----' . $v1['name']), 0, 0);
-                        $pdf->Cell(40, 8,  $this->convert('X' . $v1['total']), 0, 0, 'R');
+                        $pdf->br()->left('----' . $v1['name'], 150)->right('X' . $v1['total'], 40);
                     }
                 } else {
-                    $pdf->Ln();
-                    $pdf->Cell(150, 8,  $this->convert($v['name']), 0, 0);
-                    $pdf->Cell(40, 8,  $this->convert('X' . $v['total']), 0, 0, 'R');
+                    $pdf->br()->left($v['name'], 150)->right('X' . $v['total'], 40);
                 }
             }
         }
 
-        $pdf->Ln();
-        $pdf->Cell(0, 8,  $this->convert("----------------------------------------------------------------------------------------------------------------------------------------------"), 0, 0);
+        $pdf->hr();
 
         //$pdf->SetY(-100);
-        $manage_config = Dever::db('main/manage_config')->find();
-        $sell_config = Dever::db('main/sell_config')->find();
-        $config = Dever::db('main/config')->find();
-
-        $pdf->Ln();
-        $pdf->Cell(0, 8,  $this->convert("如遇任何问题请致电客服"), 0, 0, 'C');
-
-        $pdf->Ln();
-        $pdf->Cell(0, 8,  $this->convert("电话:" . $manage_config['phone']), 0, 0, 'C');
+        $pdf->center('如遇任何问题请致电客服');
+        $pdf->center('电话:' . $manage_config['phone']);
+        $pdf->center($config['worktime']);
 
-        $pdf->Ln();
-        $pdf->Cell(0, 8,  $this->convert($config['worktime']), 0, 0, 'C');
+        $pdf->br(2)
+        ->img($sell_config['applet'], 70)
+        ->img($manage_config['applet'], 110);
 
-        $pdf->Ln();
-        $pdf->Ln();
-        $y = $pdf->GetY();
-        $pdf->Image(Dever::pic($sell_config['applet']), 70, $y, 30, 30);
-        $pdf->Image(Dever::pic($manage_config['applet']), 110, $y, 30, 30);
+        $pdf->br(3)->center('门店零售小程序                 门店管理小程序');
 
-        $pdf->Ln(30);
-        $pdf->Cell(0, 8,  $this->convert("门店零售小程序                 门店管理小程序"), 0, 0, 'C');
-
-        $pdf->Output();
-    }
-
-    public function convert($string, $to = 'GBK', $source = 'UTF-8')
-    {
-        return mb_convert_encoding($string, $to, $source);
+        $pdf->out('库存清单');
     }
 }

+ 24 - 9
app/shop/assets/pc/html/setGoods.html

@@ -54,7 +54,7 @@
                                 <th lay-data="{field:'price', edit: 'text'}">销售价(元)</th>
                                 <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
                                 <th lay-data="{field:'number', edit: 'text'}">新增库存</th>
-                                <!--<th lay-data="{field:'operation'}">操作</th>-->
+                                <th lay-data="{field:'operation'}">操作</th>
                             </tr>
                         </thead>
                         <tbody id="goods">
@@ -128,6 +128,7 @@
         });
     })
     var goods = {};
+    var del_goods = {};
     mini.parse();
     var tree = mini.get("tree1");
     for (var i in tree.data) {
@@ -176,14 +177,16 @@
     {
         if (node.id) {
             var key = node.id;
-            if (!goods[key]) {
+            if (!goods[key] || (goods[key] && goods[key].del == 2)) {
                 goods[key] = node;
                 goods[key].price = parseFloat(goods[key].price);
+                goods[key].price_type = parseInt(goods[key].price_type);
                 goods[key].total = parseFloat(goods[key].total);
                 goods[key].num = 0;
+                goods[key].del = 1;
                 create(node);
                 setTotal();
-            } else {
+            } else if(node.price_type < 4) {
                 add(key);
             }
         }
@@ -201,9 +204,19 @@
             addtr += '<td class="goods_id">'+node.id+'</td>';
             addtr += '<td class="goods_name">'+node.name+'</td>';     
             addtr += '<td class="goods_price">'+node.price+'</td>'; 
-            addtr += '<td class="goods_price">'+node.total+'</td>';             
-            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
-            //addtr += '<td><button class="delete_btn" onclick="del(\''+node.id+'\')">删除</button></td>';                      
+            addtr += '<td class="goods_total">'+node.total+'</td>';       
+            if (node.price_type == 4) {
+                addtr += '<td>组合商品无法设置库存</td>';
+            } else {
+                addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
+            }   
+            
+            if (node.total <= 0) {
+                addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
+            } else {
+                addtr += '<td></td>';
+            }
+                                  
             addtr += '</tr>';
             $("#goods").append(addtr);
         }
@@ -229,9 +242,11 @@
 
     function del(id)
     {
-        delete goods[id];
-        get(id).remove();
-        setTotal();
+        if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            get(id).remove();
+            setTotal();
+        }
     }
 
     function setTotal()

+ 4 - 15
app/shop/database/buy_order_goods.php

@@ -71,9 +71,9 @@ return array
         'price'      => array
         (
             'type'      => 'varchar-50',
-            'name'      => '价',
+            'name'      => '价',
             'default'   => '',
-            'desc'      => '价',
+            'desc'      => '价',
             'match'     => 'option',
             'update'    => 'text',
             'list'        => true,
@@ -82,9 +82,9 @@ return array
         'p_price'     => array
         (
             'type'      => 'varchar-50',
-            'name'      => '价',
+            'name'      => '价',
             'default'   => '0',
-            'desc'      => '价',
+            'desc'      => '价',
             'match'     => 'option',
             'update'    => 'text',
         ),
@@ -100,17 +100,6 @@ return array
             'list'        => true,
         ),
 
-        'd_price'      => array
-        (
-            'type'      => 'varchar-50',
-            'name'      => '商品单价',
-            'default'   => '',
-            'desc'      => '商品单价',
-            'match'     => 'option',
-            'update'    => 'text',
-            'list'        => true,
-        ),
-
         'status'        => array
         (
             'type'      => 'int-11',

+ 1 - 1
app/shop/database/goods.php

@@ -160,7 +160,7 @@ return array
         # 列表里的按钮
         'list_button' => array
         (
-            //'fast_list' => array('库存设置', '"info_sku&project=goods&goods_id={goods_id}&other=shop&other_id={shop_id}&page_type=1"', '{price_type} <= 3'),
+            'fast_list' => array('库存设置', '"info_sku&project=goods&goods_id={goods_id}&other=shop&other_id={shop_id}&page_type=1"', '{price_type} <= 3'),
         ),
     ),
 

+ 5 - 4
app/shop/database/info.php

@@ -9,8 +9,9 @@ $status = array
 
 $type = array
 (
-    1 => '普通店',
-    2 => '平台店',
+    1 => '体验店',
+    2 => '零售店',
+    10 => '平台店',
 );
 
 $act = function()
@@ -585,9 +586,9 @@ return array
 
             'br1' => array('<br /><br />'),
 
-            'location' => array('批量设置商品', Dever::url('lib/set.home', 'shop')),
+            'location' => array('商品设置', Dever::url('lib/set.home', 'shop')),
             //'add1' => array('批量设置商品', '"info&where_id={id}&col=goods&oper_save_jump=info&oper_table=info&oper_parent=info"'),
-            'list22' => array('商品管理', '"goods&search_option_shop_id={id}&oper_table=info"'),
+            'list22' => array('商品列表', '"goods&search_option_shop_id={id}&oper_table=info"'),
 
 
             'br2' => array('<br /><br />'),

+ 2 - 13
app/shop/database/out_order_goods.php

@@ -60,9 +60,9 @@ return array
         'price'      => array
         (
             'type'      => 'varchar-50',
-            'name'      => '价',
+            'name'      => '价',
             'default'   => '',
-            'desc'      => '价',
+            'desc'      => '价',
             'match'     => 'option',
             'update'    => 'text',
             'list'        => true,
@@ -79,17 +79,6 @@ return array
             'list'        => true,
         ),
 
-        'd_price'      => array
-        (
-            'type'      => 'varchar-50',
-            'name'      => '商品单价',
-            'default'   => '',
-            'desc'      => '商品单价',
-            'match'     => 'option',
-            'update'    => 'text',
-            'list'        => true,
-        ),
-
         'status'        => array
         (
             'type'      => 'int-11',

+ 2 - 13
app/shop/database/sell_order_goods.php

@@ -62,9 +62,9 @@ return array
         'price'      => array
         (
             'type'      => 'varchar-50',
-            'name'      => '商品总价',
+            'name'      => '价',
             'default'   => '',
-            'desc'      => '商品总价',
+            'desc'      => '价',
             'match'     => 'option',
             'update'    => 'text',
             'list'        => true,
@@ -81,17 +81,6 @@ return array
             'list'        => true,
         ),
 
-        'd_price'      => array
-        (
-            'type'      => 'varchar-50',
-            'name'      => '商品单价',
-            'default'   => '',
-            'desc'      => '商品单价',
-            'match'     => 'option',
-            'update'    => 'text',
-            'list'        => true,
-        ),
-
         'coupon_id'      => array
         (
             'type'      => 'int-11',

+ 13 - 11
app/shop/lib/Info.php

@@ -37,7 +37,7 @@ class Info
 
         # 验证本城市内有没有店
         if (!$data) {
-            $data = $this->fetch(false, $city, $lng, $lat, 2, $name, $method);
+            $data = $this->fetch(false, $city, $lng, $lat, 10, $name, $method);
         }
 
         if ($data) {
@@ -88,11 +88,13 @@ class Info
         $result_2 = array();
         if ($data) {
             foreach ($data as $k => $v) {
-                $data[$k] = $this->getGoodsInfo($where['shop_id'], $v);
-                if ($data[$k]['total'] <= 0) {
-                    $result_2[] = $data[$k];
-                } else {
-                    $result_1[] = $data[$k];
+                $d = $this->getGoodsInfo($where['shop_id'], $v);
+                if ($d) {
+                    if ($d['total'] <= 0) {
+                        $result_2[] = $d;
+                    } else {
+                        $result_1[] = $d;
+                    }
                 }
             }
 
@@ -213,7 +215,6 @@ class Info
         $data = Dever::load('goods/lib/info')->getInfo($info, $attr, array($other, array('total')));
 
         if($data) {
-
             $sku_id = $sku_id ? $sku_id : $data['sku_id'];
             $data['total'] = 0;
             if ($data['price_type'] == 4) {
@@ -229,10 +230,6 @@ class Info
             } else {
                 $data['total'] = $this->getTotal($other, $sku_id);
             }
-
-            if (isset($data['goods']) && is_array($data['goods'])) {
-                //unset($data['goods']);
-            }
         }
 
         return $data;
@@ -246,7 +243,12 @@ class Info
             Dever::alert('商品不存在');
         }
         $total = $info['total'];
+        $min = $info['min'];
 
+        # 增加最小起购量
+        if ($min > 0 && $num < $min) {
+            $num = $min;
+        }
         if ($num > $total) {
             if ($state == 2) {
                 Dever::alert('库存不足');

+ 15 - 24
app/shop/lib/Refund.php

@@ -105,7 +105,6 @@ class Refund
             Dever::alert('当前订单状态不允许退货退款');
         }
 
-        $dec = $num;
         $data = Dever::load($this->lib)->set($type, 1)->getView($id, $order_id, false);
         $auth = false;
         if ($this->type == 'sell' && $type == 1) {
@@ -122,36 +121,31 @@ class Refund
             if ($order_goods_id) {
                 $info = Dever::db($this->goods_table)->find(array('id' => $order_goods_id, 'order_id' => $data['id'], 'status' => 1));
                 if ($info) {
+                    if (!$num) {
+                        $num = $info['num'];   
+                    }
                     Dever::db($this->goods_table)->update(array('where_id' => $info['id'], 'status' => 2));
+                    $info['total_price'] = $info['price'] * $num;
                 	if (isset($info['coupon_cash']) && $info['coupon_cash']) {
-                		$cash = $info['price'] - $info['coupon_cash'];
-                        $p_cash = 0;
+                		$cash = $info['total_price'] - $info['coupon_cash'];
                 	} else {
-                		$cash = $info['price'];
-                        $p_cash = $info['p_price'];
+                		$cash = $info['total_price'];
                 	}
-                    if ($num > 0) {
-                        $dec = $num;
+
+                    if (isset($info['p_price'])) {
+                        $p_cash = $info['p_price'] * $num;
                     } else {
-                        $dec = $info['num'];
-                    }
-                    
-                    if ($num > 0 && $info['num'] >= $num) {
-                        $dec = $info['num'];
-                        $price = round($cash / $info['num'], 2);
-                        $cash = round($price * $num, 2);
-
-                        if ($p_cash > 0) {
-                            $price = round($p_cash / $info['num'], 2);
-                            $p_cash = round($price * $num, 2);
-                        }
+                        $p_cash = 0;
                     }
                 } else {
                     Dever::alert('您没有权限操作');
                 }
             } else {
+                if (!$num) {
+                    $num = $data['num'];
+                }
                 $cash = $data['price'] - $data['refund_cash'];
-                if (isset($data['refund_p_cash'])) {
+                if (isset($data['p_price']) && isset($data['refund_p_cash'])) {
                     $p_cash = $data['p_price'] - $data['refund_p_cash'];
                 } else {
                     $p_cash = 0;
@@ -159,7 +153,7 @@ class Refund
             }
 
             if ($cash > 0) {
-                $log = $this->up($data['id'], $order_goods_id, $status, $cash, $p_cash, $dec, $desc, $pic, $process);
+                $log = $this->up($data['id'], $order_goods_id, $status, $cash, $p_cash, $num, $desc, $pic, $process);
 
                 if (!$log) {
                     Dever::alert('退款失败');
@@ -195,9 +189,6 @@ class Refund
                     $update['refund_p_cash'] = $data['refund_p_cash'] + $p_cash;
                 }
                 $update['refund_status'] = 2;
-                if ($dec > 0) {
-                    //$update['num'] = $data['num'] - $dec;
-                }
                 
                 Dever::db($this->order_table)->update($update);
 

+ 9 - 7
app/shop/lib/Sell.php

@@ -232,7 +232,6 @@ class Sell
         if ($this->view == 2) {
 
             foreach ($info['goods'] as $k => $v) {
-                $info['goods'][$k]['price'] = $v['d_price'] ? $v['d_price'] : round($v['price']/$v['num'], 2);
                 $info['goods'][$k]['info'] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
                 $info['goods'][$k]['status_name'] = $goods_status[$v['status']];
             }
@@ -250,7 +249,6 @@ class Sell
         } else {
             foreach ($info['goods'] as $k => $v) {
                 $goods = Dever::db('goods/info')->one($v['goods_id']);
-                $info['goods'][$k]['price'] = $v['d_price'] ? $v['d_price'] : round($v['price']/$v['num'], 2);
                 $info['goods'][$k]['name'] = $goods['name'];
                 $info['goods'][$k]['cover'] = $goods['cover'];
                 $info['goods'][$k]['status_name'] = $goods_status[$v['status']];
@@ -577,6 +575,11 @@ class Sell
             $s = isset($sku_id[$k]) ? $sku_id[$k] : -1;
             $n = isset($num[$k]) ? $num[$k] : 1;
             $data['list'][$k] = Dever::load('goods/lib/info')->getPayInfo($v, $s);
+            if (isset($data['list'][$k]['min']) && $data['list'][$k]['min'] > 0) {
+                if ($n < $data['list'][$k]['min']) {
+                    $data['list'][$k]['ku_state'] = 2;
+                }
+            }
             $data['list'][$k]['num'] = $n;
 
             # 2是库存不足
@@ -653,8 +656,7 @@ class Sell
                 $data['order_id'] = $id;
                 $data['goods_id'] = $v['id'];
                 $data['sku_id'] = $v['sku_id'];
-                $data['price'] = $v['price'] * $v['buy_num'];
-                $data['d_price'] = $v['price'];
+                $data['price'] = $v['price'];
                 $data['num'] = $v['buy_num'];
 
                 if (isset($v['user_coupon_id']) && $v['user_coupon_id']) {
@@ -1105,7 +1107,7 @@ class Sell
             );
             $result['商品清单'] = array
             (
-                'head' => array('名称', '属性', '价', '数量', '状态'),
+                'head' => array('名称', '属性', '价', '数量', '状态'),
                 'body' => $body,
             );
         }
@@ -1119,9 +1121,9 @@ class Sell
                 $refund_body_total['num'],
                 '-'
             );
-            $result['商品清单'] = array
+            $result['退款商品'] = array
             (
-                'head' => array('名称', '属性', '价', '数量', '状态'),
+                'head' => array('名称', '属性', '价', '数量', '状态'),
                 'body' => $refund_body,
             );
         }

+ 46 - 26
app/shop/lib/Set.php

@@ -57,38 +57,58 @@ class Set
             } else {
                 $sku_id = -1;
             }
-            if ($v['num'] < 1) {
+            if ($v['num'] < 0) {
             	continue;
             }
-            $w = array();
-            $w['goods_id'] = $goods_id;
-            $w['shop_id'] = $shop_id;
-            $info = Dever::db('shop/goods')->one($w);
+            if ($v['del'] == 2) {
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['shop_id'] = $shop_id;
+                $w['sku_id'] = $sku_id;
+                $sku_info = Dever::db('shop/goods_sku')->one($w);
 
-            $w['total_num'] = $v['num'];
-            if (!$info) {
-                Dever::db('shop/goods')->insert($w);
+                if ($sku_info) {
+                    Dever::db('shop/goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $total = Dever::db('shop/goods_sku')->total($w);
+                if ($total <= 0) {
+                    $info = Dever::db('shop/goods')->one($w);
+                    if ($info) {
+                        Dever::db('shop/goods')->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
             } else {
-            	$w['total_num'] += $info['total_num'];
-                $w['where_id'] = $info['id'];
-                $w['state'] = 1;
-                Dever::db('shop/goods')->update($w);
-            }
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['shop_id'] = $shop_id;
+                $info = Dever::db('shop/goods')->one($w);
 
-            $w = array();
-            $w['goods_id'] = $goods_id;
-            $w['shop_id'] = $shop_id;
-            $w['sku_id'] = $sku_id;
-            $info = Dever::db('shop/goods_sku')->one($w);
+                $w['total_num'] = $v['num'];
+                if (!$info) {
+                    Dever::db('shop/goods')->insert($w);
+                } else {
+                    $w['total_num'] += $info['total_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('shop/goods')->update($w);
+                }
 
-            $w['total_num'] = $v['num'];
-            if (!$info) {
-                Dever::db('shop/goods_sku')->insert($w);
-            } else {
-            	$w['total_num'] += $info['total_num'];
-                $w['where_id'] = $info['id'];
-                $w['state'] = 1;
-                Dever::db('shop/goods_sku')->update($w);
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['shop_id'] = $shop_id;
+                $w['sku_id'] = $sku_id;
+                $info = Dever::db('shop/goods_sku')->one($w);
+
+                $w['total_num'] = $v['num'];
+                if (!$info) {
+                    Dever::db('shop/goods_sku')->insert($w);
+                } else {
+                    $w['total_num'] += $info['total_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('shop/goods_sku')->update($w);
+                }
             }
         }
 

+ 81 - 0
app/store/admin/Goods.php

@@ -52,6 +52,87 @@ class Goods extends Core
     public function getConfig()
     {
     	$data['search'] = Dever::url('goods', 'store');
+        $data['print'] = Dever::url('admin/goods.print', 'store');
     	return $data;
     }
+
+    # 打印订单单
+    public function print_api()
+    {
+        $factory_config = Dever::db('main/factory_config')->find();
+        $main_config = Dever::db('main/config')->find();
+        $config = Dever::db('main/config')->find();
+        $data = Dever::load('store/lib/goods')->getGoodsSku($this->id);
+        $store = Dever::db('store/info')->find($this->id);
+
+
+        $pdf = Dever::load('pdf/lib/base')->init();
+
+        $pdf->hr('-', $config['name']);
+
+        $pdf->br()->font(20)->center('库存清单');
+        $pdf->font(10);
+        $pdf->br(2);
+
+        $pdf->br()->left('仓库名称:' . $store['name'], 80)->left('制单人:' . $this->user['name'], 60)->left('制单时间:' . date('Y-m-d H:i'), 40);
+
+        $pdf->hr();
+
+        $head = array(array('商品编号', 40), array('商品名称', 70), array('商品属性', 60), array('数量', 20));
+
+        if ($data) {
+            $body = array();
+            $body_total = array();
+            $body_total['num'] = 0;
+
+            foreach ($data as $k => $v) {
+
+                $v['sku_name'] = isset($v['sku_name']) ? $v['sku_name'] : '无';
+                $body[] = array
+                (
+                    $v['id'],
+                    $v['name'],
+                    $v['sku_name'],
+                    'x ' . $v['total'],
+                );
+
+                $body_total['num'] += $v['total'];
+            }
+
+            $pdf->br();
+            foreach ($head as $k => $v) {
+                $pdf->left($v[0], $v[1]);
+            }
+
+            foreach ($body as $k => $v) {
+                $pdf->br();
+                foreach ($head as $k1 => $v1) {
+                    $pdf->left($v[$k1], $v1[1]);
+                }
+            }
+            $pdf->br();
+            $pdf->right('共'.$body_total['num'].'件商品');
+            $pdf->hr();
+        }
+
+        $pdf->br(1);
+        
+        $pdf->right('如遇任何问题请致电客服');
+        $pdf->br();
+
+        $pdf->font(20);
+        $pdf->left($main_config['name'], 160);
+
+        $pdf->font(10);
+        $pdf->right('电话:' . $factory_config['phone'], 30);
+
+        $pdf->br();
+
+        $pdf->left($main_config['site'], 160);
+
+        $pdf->font(10);
+        $pdf->right($main_config['worktime'], 30);
+
+        $pdf->out('库存清单');
+    }
 }

+ 13 - 4
app/store/admin/Order.php

@@ -17,7 +17,7 @@ class Order extends Core
 		$data['order_num'] = Dever::db('shop/buy_order')->getOrderNum($where);
 
 		# 超时待处理订单:72小时
-		$where['end_o'] = time() + 72*3600;
+		$where['end_o'] = time() - 72*3600;
 		$data['cs_order_num'] = Dever::db('shop/buy_order')->getOrderNum($where);
 
         # 超时待处理订单:72小时
@@ -25,7 +25,7 @@ class Order extends Core
         $where['status'] = 4;
         $where['type'] = 2;
         $where['type_id'] = $this->id;
-        $where['end_o'] = time() + 72*3600;
+        $where['end_o'] = time() - 72*3600;
 
         $data['sh_order_num'] = Dever::db('shop/buy_order')->getOrderNum($where);
 
@@ -47,12 +47,15 @@ class Order extends Core
         		}
         		$view = Dever::url('order_view?type=3&order_id=' . $v['id'], 'store');
 
-        		$send = Dever::url('order_send?id=' . $v['id'], 'store');
+        		$send = Dever::url('order_send?id=' . $v['id'] . '&type=2', 'store');
 
         		$button = '<a href="'.$view.'"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看详情</button></a>';
 
         		if ($v['status'] < 5) {
-        			$button .= '&nbsp;&nbsp;<a href="javascript:;" id="print_'.$v['id'].'" onclick="layer.alert(\'开发中\')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">打印备货单</button></a>';
+
+                    $print = Dever::url('admin/order.print?id=' . $v['id'] . '&type=2', 'store');
+
+        			$button .= '&nbsp;&nbsp;<a href="'.$print.'" id="print_'.$v['id'].'" target="_blank"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">打印备货单</button></a>';
         		}
         		
         		if ($v['status'] == 3) {
@@ -137,6 +140,7 @@ class Order extends Core
     	$update = $where;
     	$update['service_id'] = $input['update_service_id'];
     	$update['order_num'] = $input['update_order_num'];
+        $update['num'] = $input['update_num'];
     	$update['phy'] = $input['update_phy'];
     	$update['dby'] = $input['update_dby'];
     	$update['zl'] = $input['update_zl'];
@@ -153,4 +157,9 @@ class Order extends Core
 
     	return 'reload';
     }
+
+    public function print_api()
+    {
+        return Dever::load('mshop/lib/buy')->printer($this->user);
+    }
 }

+ 5 - 0
app/store/admin/Out.php

@@ -195,4 +195,9 @@ class Out extends Core
 
         return Dever::url('out', 'store');
     }
+
+    public function print_api()
+    {
+        return Dever::load('mshop/lib/out')->printer($this->user);
+    }
 }

+ 7 - 1
app/store/admin/Stat.php

@@ -39,7 +39,7 @@ class Stat extends Core
         		}
 
 
-        		$html .= '<tr><td>'.Dever::load("cash/lib/set.statDate", $v['type'], $v['day']).'</td><td>'.Dever::load("cash/lib/set.statTime", $v['start'], $v['end']).'</td><td>'.round($v['cash'], 2).'</td><td>'.$config['config_status'][$v['store_status']].'</td><td>'.$button.'</td></tr>';
+        		$html .= '<tr><td>'.Dever::load("cash/lib/set.statDate", $v['type'], $v['day']).'</td><td>'.Dever::load("cash/lib/set.statTime", $v['start'], $v['end']).'</td><td>'.$v['num'].'</td><td>'.$config['config_status'][$v['store_status']].'</td><td>'.$button.'</td></tr>';
         	}
         }
         return $html;
@@ -77,4 +77,10 @@ class Stat extends Core
 
     	return $data;
     }
+
+    # 打印订单单
+    public function print_api()
+    {
+        return Dever::load('cash/lib/set')->printer($this->user);
+    }
 }

+ 1 - 1
app/store/assets/pc/html/goods.html

@@ -23,7 +23,7 @@
 
           <div class="layui-form layui-card-header layuiadmin-card-header-auto">
             <div class="layui-form-item">
-              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="name" id="name" autocomplete="off" placeholder="商品名称"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="total" id="total"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" onclick="out()" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">打印清单</button></div></div></div></div>
+              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="name" id="name" autocomplete="off" placeholder="商品名称"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="total" id="total"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<a class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" id="print" target="_blank" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">打印清单</a></div></div></div></div>
             </div>
           </div>
         </div>

+ 1 - 1
app/store/assets/pc/html/order.html

@@ -23,7 +23,7 @@
 
           <div class="layui-form layui-card-header layuiadmin-card-header-auto">
             <div class="layui-form-item">
-              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="order_num" id="order_num" autocomplete="off" placeholder="订单编号"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder=">=订货时间" name="start" id="start" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder="<=订货时间" name="end" id="end" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="status" id="status"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" onclick="out($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">批量打印备货单</button></div></div></div></div>
+              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="order_num" id="order_num" autocomplete="off" placeholder="订单编号"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder=">=订货时间" name="start" id="start" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder="<=订货时间" name="end" id="end" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="status" id="status"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" onclick="out($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;display:none;">批量打印备货单</button></div></div></div></div>
             </div>
           </div>
         </div>

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
app/store/assets/pc/html/order_send.html


+ 1 - 1
app/store/assets/pc/html/out.html

@@ -31,7 +31,7 @@
         <div style="padding-bottom: 10px;">
           <a class="layui-btn layuiadmin-btn-list" data-type="add" id="list-parent" style="display:none" href="">返回上一页</a>
 
-          <a class="layui-btn layuiadmin-btn-list" data-type="add" id="list-add" href="http://zsmatest.nongxiaohe.com/package/manage/?l=project/database/update&amp;project=shop&amp;search_option_type=2&amp;table=buy_order&amp;menu=shop&amp;menu_id=99&amp;search_option_state=1">新增</a>
+          <a class="layui-btn layuiadmin-btn-list" data-type="add" style="display:none;" id="list-add" href="http://zsmatest.nongxiaohe.com/package/manage/?l=project/database/update&amp;project=shop&amp;search_option_type=2&amp;table=buy_order&amp;menu=shop&amp;menu_id=99&amp;search_option_state=1">新增</a>
 
           <span id="list-button"></span>
         </div>

+ 20 - 8
app/store/assets/pc/html/setGoodsNum.html

@@ -54,7 +54,7 @@
                                 <th lay-data="{field:'price', edit: 'text'}">销售价(元)</th>
                                 <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
                                 <th lay-data="{field:'number', edit: 'text'}">新增库存</th>
-                                <!--<th lay-data="{field:'operation'}">操作</th>-->
+                                <th lay-data="{field:'operation'}">操作</th>
                             </tr>
                         </thead>
                         <tbody id="goods">
@@ -176,14 +176,16 @@
     {
         if (node.id) {
             var key = node.id;
-            if (!goods[key]) {
+            if (!goods[key] || (goods[key] && goods[key].del == 2)) {
                 goods[key] = node;
                 goods[key].price = parseFloat(goods[key].price);
+                goods[key].price_type = parseInt(goods[key].price_type);
                 goods[key].total = parseFloat(goods[key].total);
                 goods[key].num = 0;
+                goods[key].del = 1;
                 create(node);
                 setTotal();
-            } else {
+            } else if(node.price_type < 4) {
                 add(key);
             }
         }
@@ -202,8 +204,16 @@
             addtr += '<td class="goods_name">'+node.name+'</td>';     
             addtr += '<td class="goods_price">'+node.price+'</td>'; 
             addtr += '<td class="goods_price">'+node.total+'</td>';             
-            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
-            //addtr += '<td><button class="delete_btn" onclick="del(\''+node.id+'\')">删除</button></td>';                      
+            if (node.price_type == 4) {
+                addtr += '<td>组合商品无法设置库存</td>';
+            } else {
+                addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
+            } 
+            if (node.total <= 0) {
+                addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
+            } else {
+                addtr += '<td></td>';
+            }                 
             addtr += '</tr>';
             $("#goods").append(addtr);
         }
@@ -229,9 +239,11 @@
 
     function del(id)
     {
-        delete goods[id];
-        get(id).remove();
-        setTotal();
+        if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            get(id).remove();
+            setTotal();
+        }
     }
 
     function setTotal()

+ 1 - 1
app/store/assets/pc/html/stat.html

@@ -51,7 +51,7 @@
           <div id="chart" class="chart" style="display:none"></div>
           <table class="table layui-table layui-table-body" id="table">
           <thead id="list-thead">
-              <tr><th data-priority="1">对账单时间</th><th data-priority="1">对账周期</th><th data-priority="1">对账金额</th><th data-priority="1">对账状态</th><th data-priority="1" class="dever-manage">管理</th></tr>
+              <tr><th data-priority="1">对账单时间</th><th data-priority="1">对账周期</th><th data-priority="1">对账数量</th><th data-priority="1">对账状态</th><th data-priority="1" class="dever-manage">管理</th></tr>
           </thead>
           <tbody id="list-tbody"><tr><td>2021年11月</td><td>第二个仓库</td><td>2021-11-01 ~ 2021-11-30</td><td>40</td><td>未对账</td><td>未对账</td><td><a href="http://192.168.33.10/churen/package/manage/?l=project/database/list&project=cash&&page_type=2&table=order&project=cash&id=2&page_type=1&type=store&menu=cash&menu_id=88&search_option_state=1" class="oper_list"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs"><span class="am-icon-pencil-square-o"></span>查看详情</button></a>&nbsp;&nbsp;<a href="javascript:;" onclick="load('http://192.168.33.10/churen/app/cash/?l=lib/manage.audit&id=2&type=store', '2021年11月与第二个仓库对账单款项是否正确<br />对账金额¥40元', '请确认')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">确认对账金额</button></a>&nbsp;&nbsp;</td></tr><tr><td>2021年11月</td><td>第二个仓库</td><td>2021-11-01 ~ 2021-11-30</td><td>0</td><td>未对账</td><td>未对账</td><td><a href="http://192.168.33.10/churen/package/manage/?l=project/database/list&project=cash&&page_type=2&table=order&project=cash&id=1&page_type=1&type=store&menu=cash&menu_id=88&search_option_state=1" class="oper_list"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs"><span class="am-icon-pencil-square-o"></span>查看详情</button></a>&nbsp;&nbsp;<a href="javascript:;" onclick="load('http://192.168.33.10/churen/app/cash/?l=lib/manage.audit&id=1&type=store', '2021年11月与第二个仓库对账单款项是否正确<br />对账金额¥0元', '请确认')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">确认对账金额</button></a>&nbsp;&nbsp;</td></tr></tbody>
       </table>

+ 1 - 1
app/store/database/info.php

@@ -334,7 +334,7 @@ return array
     (
         'list_button' => array
         (
-            'location' => array('批量设置商品', Dever::url('lib/set.home', 'store')),
+            'location' => array('商品设置', Dever::url('lib/set.home', 'store')),
             //'add' => array('设置库存清单', '"info&where_id={id}&col=goods&oper_save_jump=info&oper_table=info&oper_parent=info"'),
 
             'list3' => array('商品列表', '"goods&search_option_store_id={id}&oper_table=info"'),

+ 2 - 2
app/store/lib/Goods.php

@@ -98,11 +98,11 @@ class Goods
         $result = array();
         if ($data) {
             foreach ($data as $k => $v) {
-                $data[$k] = Dever::load('goods/lib/info')->getPayInfo($v, $v['sku_id']);
+                $data[$k] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
                 if ($data[$k]['price_type'] == 4) {
                     continue;
                 }
-                $data[$k]['total'] = $data[$k]['total'] ? $data[$k]['total'] : 0;
+                $data[$k]['total'] = $v['total'] ? $v['total'] : 0;
                 if ($data[$k]['total'] <= 0) {
                     continue;
                 }

+ 47 - 26
app/store/lib/Set.php

@@ -57,38 +57,59 @@ class Set
             } else {
                 $sku_id = -1;
             }
-            if ($v['num'] < 1) {
+            if ($v['num'] < 0) {
             	continue;
             }
-            $w = array();
-            $w['goods_id'] = $goods_id;
-            $w['store_id'] = $store_id;
-            $info = Dever::db('store/goods')->one($w);
 
-            $w['total_num'] = $v['num'];
-            if (!$info) {
-                Dever::db('store/goods')->insert($w);
+            if ($v['del'] == 2) {
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['store_id'] = $store_id;
+                $w['sku_id'] = $sku_id;
+                $sku_info = Dever::db('store/goods_sku')->one($w);
+
+                if ($sku_info) {
+                    Dever::db('store/goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $total = Dever::db('store/goods_sku')->total($w);
+                if ($total <= 0) {
+                    $info = Dever::db('store/goods')->one($w);
+                    if ($info) {
+                        Dever::db('store/goods')->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
             } else {
-            	$w['total_num'] += $info['total_num'];
-                $w['where_id'] = $info['id'];
-                $w['state'] = 1;
-                Dever::db('store/goods')->update($w);
-            }
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['store_id'] = $store_id;
+                $info = Dever::db('store/goods')->one($w);
 
-            $w = array();
-            $w['goods_id'] = $goods_id;
-            $w['store_id'] = $store_id;
-            $w['sku_id'] = $sku_id;
-            $info = Dever::db('store/goods_sku')->one($w);
+                $w['total_num'] = $v['num'];
+                if (!$info) {
+                    Dever::db('store/goods')->insert($w);
+                } else {
+                	$w['total_num'] += $info['total_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('store/goods')->update($w);
+                }
 
-            $w['total_num'] = $v['num'];
-            if (!$info) {
-                Dever::db('store/goods_sku')->insert($w);
-            } else {
-            	$w['total_num'] += $info['total_num'];
-                $w['where_id'] = $info['id'];
-                $w['state'] = 1;
-                Dever::db('store/goods_sku')->update($w);
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['store_id'] = $store_id;
+                $w['sku_id'] = $sku_id;
+                $info = Dever::db('store/goods_sku')->one($w);
+
+                $w['total_num'] = $v['num'];
+                if (!$info) {
+                    Dever::db('store/goods_sku')->insert($w);
+                } else {
+                	$w['total_num'] += $info['total_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('store/goods_sku')->update($w);
+                }
             }
         }
 

+ 1 - 0
app/store/template/pc/goods.php

@@ -10,6 +10,7 @@ $view
 ->fetch('#content_2@test', '1')  
 ->fetch('#total', 'store/admin/goods.getSearch') 
 ->fetch('#form1@action', 'store/admin/goods.getConfig#search') 
+->fetch('#print@href', 'store/admin/goods.getConfig#print') 
 
 ->fetch('#list-tbody', 'store/admin/goods.getList') 
 

+ 10 - 0
main/database/config.php

@@ -42,6 +42,16 @@ return array
 			'update'	=> 'text',
 		),
 
+        'site'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '网站地址',
+            'default'   => '',
+            'desc'      => '网站地址',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
 		'logo'		=> array
 		(
 			'type' 		=> 'varchar-150',

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels