dever 3 years ago
parent
commit
b5bf37f957

+ 15 - 0
app/factory/admin/Order.php

@@ -115,6 +115,9 @@ class Order extends Core
 
     	# 发货
     	$data['send'] = Dever::url('admin/order.send', 'factory');
+
+        # 退款
+        $data['tui'] = Dever::url('lib/buy.refund_apply_info_one_commit?json=1', 'mshop');
     	return $data;
     }
 
@@ -165,4 +168,16 @@ class Order extends Core
         return Dever::load('mshop/lib/buy')->printer($this->user);
     }
 
+    # 获取报损信息
+    public function refund()
+    {
+        $data = Dever::load('mshop/lib/buy')->refund_apply_info_one_info();
+
+        if (isset($data['tui_price'])) {
+            $data['tui_price_info'] = '¥' . $data['tui_price'];
+        } else {
+            $data['tui_price_info'] = '¥0';
+        }
+        return $data;
+    }
 }

File diff suppressed because it is too large
+ 19 - 0
app/factory/assets/pc/html/order_tui.html


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

@@ -93,11 +93,11 @@ function tui(goods_id, order_id, source_id, status, url)
     })
 }
 
-function cancel(order_id, source_id, url)
+function cancel(url)
 {
     var index = layer.confirm('确定要取消该订单吗?', function()
     {
-        $.getJSON(url, {order_id:order_id,type_id:source_id,type:13,desc:'厂家上报'}, function(t)
+        $.getJSON(url, {type:13,desc:'厂家上报'}, function(t)
         {
             msg(t);
         })

+ 18 - 0
app/factory/template/pc/order_tui.php

@@ -0,0 +1,18 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| home
+|--------------------------------------------------------------------------
+*/
+$view
+
+# 定义名称
+->fetch('.form1@action', 'factory/admin/order.getConfig#tui') 
+->fetch('#order_id@value', '<{Dever::input("order_id")}>')
+->fetch('#order_goods_id@value', '<{Dever::input("order_goods_id")}>')
+->fetch('#type@value', '<{Dever::input("type")}>') 
+->fetch('#type_id@value', '<{Dever::input("type_id")}>') 
+->fetch('#cash', 'factory/admin/order.refund#tui_price_info') 
+
+# display
+->display();

+ 243 - 177
app/mshop/lib/Buy.php

@@ -520,6 +520,17 @@ class Buy
         return Dever::load('shop/lib/refund')->set('buy')->apply($type, $type_id, $order_id, false, $status, 0, $desc, $pic, 1);
     }
 
+    # 部分退款信息 报损
+    public function refund_apply_info_one_info()
+    {
+        $order_id = Dever::input('order_id');
+        $order_goods_id = Dever::input('order_goods_id');
+        $type = Dever::input('type');
+        $type_id = Dever::input('type_id');
+
+        return Dever::load('shop/lib/refund')->set('buy')->getInfo($type, $type_id, $order_id, $order_goods_id);
+    }
+
     # 部分退款 报损
     public function refund_apply_info_one_commit_api()
     {
@@ -567,49 +578,26 @@ class Buy
         } else {
             $fdate = '';
         }
-        
-        
-        $html = '<div class="layui-col-md12"><div class="layui-card"><div class="layui-card-header">基本信息</div><div class="layui-card-body">';
-        $html .= '<table class="layui-table"><thead><tr><th style="width:20%">项目</th><th style="width:80%">详情</th></tr> </thead><tbody>';
 
         if ($type == 2 || $info['type'] == 2) {
             $info['price'] = $info['p_price'];
         }
 
-        if ($type == 3) {
-            $html .= '<tr>
-              <td>订单信息</td>
-              <td>'.$this->table(false, array(array('订单号:' . $info['order_num'], '数量:' . $info['num'], '状态:' . $status))).'</td>
-
-            </tr>';
-        } else {
-            $html .= '<tr>
-              <td>订单信息</td>
-              <td>'.$this->table(false, array(array('订单号:' . $info['order_num'], '金额:' . $info['price'], '数量:' . $info['num'], '状态:' . $status))).'</td>
-
-            </tr>';
-        }
-        
-
         if ($type == 1 && $tk && $tk['process'] == 1) {
             $status = '申请' . $tk_status[$tk['status']];
         }
 
+        $time = array();
         if ($type == 1) {
-            $time = array('下单时间:' . $cdate, '订货时间:' . $operdate);
+            $time[] = array('下单时间', $cdate);
+            $time[] = array('订货时间', $operdate);
         } else {
-            $time = array('订货时间:' . $operdate);
+            $time[] = array('订货时间', $operdate);
         }
 
         if ($fdate) {
-            $time[] = '完成时间:' . $fdate;
+            $time[] = array('完成时间', $fdate);
         }
-        
-        $html .= '<tr>
-          <td>订单时间</td>
-          <td>'.$this->table(false, array($time)).'</td>
-
-        </tr>';
 
         if ($info['type'] == 1) {
             $type_info = Dever::db('shop/info')->find($info['type_id']);
@@ -619,11 +607,34 @@ class Buy
             $type_info = Dever::db('store/info')->find($info['type_id']);
         }
 
-        $html .= '<tr>
-          <td>配送信息</td>
-          <td>'.$this->table(false, array(array($type_info['name']  . '' . $type_info['truename'] . '' . $type_info['mobile'] . '' . $type_info['address']))).'</td>
+        $result = array();
 
-        </tr>';
+        $result[$info['order_num']] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('订单状态', $status),
+                ),
+
+                $time,
+                
+                array
+                (
+                    array('配送至', $type_info['name']),
+                    array('配送地址', $type_info['address']),
+                ),
+
+                array
+                (
+                    array('联系人', $type_info['truename']),
+                    array('联系电话', $type_info['mobile']),
+                    array('订单备注', $info['info']),
+                ),
+            )
+        );
 
 
         if ($type == 1 && $info['source_id'] > 0) {
@@ -634,65 +645,84 @@ class Buy
                 # 工厂
                 $source_info = Dever::db('factory/info')->find($info['source_id']);
             }
-            $html .= '<tr>
-                  <td>供应商信息</td>
-                  <td>'.$this->table(false, array(array($source_info['name']  . '' . $source_info['truename'] . '' . $source_info['mobile']))).'</td>
-
-                </tr>';
-        }
-        
-        if ($info['info']) {
-            $html .= '<tr>
-              <td>订单备注</td>
-              <td>'.$this->table(false, array(array($info['info']))).'</td>
 
-            </tr>';
+            $result[$info['order_num']]['content'][] = array
+            (
+                array('供应商', $source_info['name']),
+                array('联系人', $source_info['truename']),
+                array('联系电话', $source_info['mobile']),
+            );
         }
 
+        $button = array();
         if ($type == 2) {
             $config = Dever::load('factory/admin/auth.config');
-            $button = array();
+            
             if ($info['status'] < 5) {
-                $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>';
+                $button[] = array
+                (
+                    'type' => 'link',
+                    'link' => Dever::url('admin/order.print?id=' . $info['id'] . '&type=1', 'factory'),
+                    'name' => '打印货单',
+                );
             }
             if ($info['status'] == 3) {
-                $send = Dever::url('order_send?id=' . $info['id'], 'factory');
-                $cancel = Dever::url('lib/buy.refund_apply_commit?json=1', 'mshop');
-                $button[] = '<button class="layui-btn layui-btn-primary" onclick="fastEdit($(this), \''.$send.'\', \'配送发货\', \'\', 1)">配送发货</button>';
-                $button[] = '<button class="layui-btn layui-btn-primary" onclick="cancel('.$info['id'].','.$info['source_id'].', \''.$cancel.'\')">取消订单</button>';
+                $button[] = array
+                (
+                    'type' => 'edit',
+                    'link' => Dever::url('order_send?id=' . $info['id'], 'factory'),
+                    'name' => '配送发货',
+                );
+
+                $button[] = array
+                (
+                    'type' => 'cancel',
+                    'link' => Dever::url('lib/buy.refund_apply_commit?json=1&order_id=' . $info['id'] . '&type_id=' . $info['source_id'], 'mshop'),
+                    'name' => '取消订单',
+                );
             }
             $config['phone'] = '您的专属客服:' . $config['kf_name'] . ',联系电话:' . $config['phone'];
-            $button[] = '<button class="layui-btn layui-btn-primary" onclick="showAlert(\''.$config['phone'].'\')">联系平台</button>';
-            $html .= '<tr>
-                  <td>功能按钮</td>
-                  <td>'.$this->table(false, array($button)).'</td>
-
-                </tr>';
+            $button[] = array
+            (
+                'type' => 'alert',
+                'content' => $config['phone'],
+                'name' => '联系平台',
+            );
         } elseif ($type == 3) {
             $config = Dever::load('factory/admin/auth.config');
-            $button = array();
-            $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>';
+
+            $button[] = array
+            (
+                'type' => 'link',
+                'link' => Dever::url('admin/order.print?id=' . $info['id'] . '&type=2', 'store'),
+                'name' => '打印货单',
+            );
+
             if ($info['status'] == 3 && $info['type'] == 1) {
-                $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>';
+                $button[] = array
+                (
+                    'type' => 'edit',
+                    'link' => Dever::url('order_send?id=' . $info['id'] . '&type=2', 'store'),
+                    'name' => '配送发货',
+                );
             }
             if ($info['status'] == 4 && $info['type'] == 2) {
-                $url = Dever::url('admin/factory_order.action_commit?order_id='.$info['id'], 'store');
-                $button[] = '<button class="layui-btn layui-btn-primary" onclick="load(\''.$url.'\')">确认收货</button>';
+                $button[] = array
+                (
+                    'type' => 'action',
+                    'link' => Dever::url('admin/factory_order.action_commit?order_id='.$info['id'], 'store'),
+                    'name' => '确认收货',
+                );
             }
             $config['phone'] = '您的专属客服:' . $config['kf_name'] . ',联系电话:' . $config['phone'];
-            $button[] = '<button class="layui-btn layui-btn-primary" onclick="showAlert(\''.$config['phone'].'\')">联系平台</button>';
-            $html .= '<tr>
-                  <td>功能按钮</td>
-                  <td>'.$this->table(false, array($button)).'</td>
-
-                </tr>';
+            $button[] = array
+            (
+                'type' => 'alert',
+                'content' => $config['phone'],
+                'name' => '联系平台',
+            );
         }
 
-        $html .= '</tbody></table></div></div>';
-
         $url = Dever::url('lib/buy.refund_commit?json=1', 'mshop');
         if (!$info['refund_cash']) {
             $info['refund_cash'] = 0;
@@ -709,20 +739,34 @@ class Buy
             $desc['退款原因'] = $tk['desc'];
             $desc['退款图片'] = '暂无';
             if ($tk['pic']) {
-                $desc['退款图片'] = '';
                 $pic = explode(',', $tk['pic']);
+                $tk['pic'] = '';
                 foreach ($pic as $k => $v) {
-                    $desc['退款图片'] .= '<a href="'.$v.'" target="_blank"><img src="'.$v.'" width="100"/></a>';
+                    $tk['pic'] .= '<a href="'.$v.'" target="_blank"><img src="'.$v.'" width="100"/></a>';
                 }
             }
-            $tk['desc'] = '<a href="javascript:showAlert($(\'#desc_content\').html());">查看</a><span id="desc_content" style="display:none">'.Dever::table($desc).'</span>';
-
-            $head = array('退款金额', '数量', '退款原因', '退款进度');
-
-            $body = array(array($info['refund_cash'], $info['num'], $tk['desc'], $process));
-
-            $html .= '<div class="layui-card"><div class="layui-card-header">退款信息</div><div class="layui-card-body">' . $this->table($head, $body) . '</div></div>';
-
+;
+            $tk['cdate'] = date('Y-m-d H:i', $tk['cdate']);
+            $result['退款信息'] = array
+            (
+                'type' => 'info',
+                'content' => array
+                (
+                    array
+                    (
+                        array('退款金额', $info['refund_cash']),
+                        array('数量', $info['num']),
+                        array('退款进度', $process),
+                    ),
+
+                    array
+                    (
+                        array('申请时间', $tk['cdate']),
+                        array('申请原因', $tk['desc']),
+                        array('图片', $tk['pic']),
+                    ),
+                ),
+            );
         }
 
         $info['ps_info'] = Dever::db('shop/buy_order_ps')->find(array('order_id' => $info['id']));
@@ -746,17 +790,66 @@ class Buy
 
             $info['ps_info']['order_num'] = str_replace("\r\n", ',', $info['ps_info']['order_num']);
             if ($type == 3) {
-                $head = array('名称', '单号', '数量', '重量', '体积', '发货时间', '收货时间');
-
-                $body = array(array($info['ps_info']['service_name'], $info['ps_info']['order_num'], $info['ps_info']['num'], $info['ps_info']['zl'], $info['ps_info']['tj'], $info['ps_info']['cdate'], $info['ps_info']['ydate']));
+                $result['物流信息'] = array
+                (
+                    'type' => 'info',
+                    'content' => array
+                    (
+                        array
+                        (
+                            array('名称', $info['ps_info']['service_name']),
+                            array('单号', $info['ps_info']['order_num']),
+                        ),
+
+                        array
+                        (
+                            array('数量', $info['ps_info']['num']),
+                            array('重量', $info['ps_info']['zl']),
+                            array('体积', $info['ps_info']['tj']),
+                        ),
+
+                        array
+                        (
+                            array('发货时间', $info['ps_info']['cdate']),
+                            array('收货时间', $info['ps_info']['ydate']),
+                        ),
+                    ),
+                );
             } else {
-                $head = array('名称', '单号', '费用', '数量', '重量', '体积', '配货员', '打包员', '发货时间', '收货时间');
 
-                $body = array(array($info['ps_info']['service_name'], $info['ps_info']['order_num'], $info['ps_info']['price'], $info['ps_info']['num'], $info['ps_info']['zl'], $info['ps_info']['tj'], $info['ps_info']['phy'], $info['ps_info']['dby'], $info['ps_info']['cdate'], $info['ps_info']['ydate']));
+                $result['物流信息'] = array
+                (
+                    'type' => 'info',
+                    'content' => array
+                    (
+                        array
+                        (
+                            array('名称', $info['ps_info']['service_name']),
+                            array('单号', $info['ps_info']['order_num']),
+                            array('费用', $info['ps_info']['price']),
+                        ),
+
+                        array
+                        (
+                            array('配货员', $info['ps_info']['phy']),
+                            array('打包员', $info['ps_info']['dby']),
+                        ),
+
+                        array
+                        (
+                            array('数量', $info['ps_info']['num']),
+                            array('重量', $info['ps_info']['zl']),
+                            array('体积', $info['ps_info']['tj']),
+                        ),
+
+                        array
+                        (
+                            array('发货时间', $info['ps_info']['cdate']),
+                            array('收货时间', $info['ps_info']['ydate']),
+                        ),
+                    ),
+                );
             }
-            
-
-            $html .= '<div class="layui-card"><div class="layui-card-header">物流信息</div><div class="layui-card-body">' . $this->table($head, $body) . '</div></div>';
         }
 
         
@@ -797,17 +890,22 @@ class Buy
                             $desc['退款图片'] .= '<a href="'.$v1.'" target="_blank"><img src="'.$v1.'" width="100"/></a>';
                         }
                     }
-                    $status .= '&nbsp;&nbsp;<a href="javascript:showAlert($(\'#desc_content\').html());">查看原因</a><span id="desc_content" style="display:none">'.Dever::table($desc).'</span>';
+                    $status .= '<div style="width:300px"><table><tr><td><a href="javascript:showAlert($(\'#desc_content\').html());">点此查看原因</a><span id="desc_content" style="display:none">'.Dever::table($desc).'</span><td>';
 
-                    $status .= '&nbsp;&nbsp;<a href="javascript:;" onclick="audit('.$tk['id'].', 2, \''.$url.'\')" class="layui-btn">通过</a><a href="javascript:;" onclick="audit('.$tk['id'].', 3, \''.$url.'\')" class="layui-btn layui-btn-danger">驳回</a>';
+                    $status .= '<td><button href="javascript:;" style="width:80px" onclick="audit('.$tk['id'].', 2, \''.$url.'\')" class="layui-btn layui-btn-primary">通过</button></td><td><button href="javascript:;" onclick="audit('.$tk['id'].', 3, \''.$url.'\')"  style="width:80px" class="layui-btn layui-btn-danger">驳回</button></td></tr></table></div>';
                 }
             } elseif ($type > 1 && (!$tk || ($tk && $tk['process'] == 3))) {
 
-                $tui = Dever::url('lib/buy.refund_apply_info_one_commit?json=1', 'mshop');
+                //$tui = Dever::url('lib/buy.refund_apply_info_one_commit?json=1', 'mshop');
+                if ($type == 2) {
+                    $tui = Dever::url('order_tui?order_goods_id=' . $v['id'] . '&order_id=' . $info['id'] . '&type=13&type_id=' . $info['source_id'], 'factory');
+                } else {
+                    $tui = Dever::url('order_tui?order_goods_id=' . $v['id'] . '&order_id=' . $info['id'] . '&type=12&type_id=' . $info['source_id'], 'store');
+                }
                 if ($info['status'] == 3) {
-                    $status = '<a href="javascript:;" onclick="tui('.$v['id'].','.$info['id'].','.$info['source_id'].', 2, \''.$tui.'\')" class="layui-btn">缺货退款</a>';
+                    $status = '<a href="javascript:;" onclick="fastEdit($(this), \''.$tui.'\', \'缺货退款\', \'\', 1)" class="layui-btn">缺货退款</a>';
                 } elseif ($info['status'] == 4) {
-                    $status = '<a href="javascript:;" onclick="tui('.$v['id'].','.$info['id'].','.$info['source_id'].', 1, \''.$tui.'\')" class="layui-btn">报损退款</a>';
+                    $status = '<a href="javascript:;" onclick="fastEdit($(this), \''.$tui.'\', \'报损退款\', \'\', 1)" class="layui-btn">报损退款</a>';
                 }
             }
 
@@ -817,31 +915,28 @@ class Buy
                 $sku = '';
             }
 
+            $d = array
+            (
+                'pic' => $goods_info['cover'],
+                'name' => $goods_info['name'],
+                'sku' => $sku,
+                'price' => $v['price'],
+                'num' => $v['num'],
+                'status' => $status,
+            );
+
             if ($tk && $v['status'] == 3 && $tk['status'] != 3) {
-                $d = array
-                (
-                    $goods_info['name'] . ' ' . $sku,
-                    $v['price'],
-                    $v['num'],
-                    $tk_status[$tk['status']],
-                );
+                $d['status'] = $tk_status[$tk['status']];
                 if ($type == 3) {
-                    unset($d[1]);
+                    unset($d['price']);
                 }
                 $refund_body[] = $d;
                 $price = $v['price']*$v['num'];
                 $refund_body_total['price'] += $price;
                 $refund_body_total['num'] += $v['num'];
             } else {
-                $d = array
-                (
-                    $goods_info['name'] . ' ' . $sku,
-                    $v['price'],
-                    $v['num'],
-                    $status,
-                );
                 if ($type == 3) {
-                    unset($d[1]);
+                    unset($d['price']);
                 }
                 $body[] = $d;
                 $price = $v['price']*$v['num'];
@@ -852,44 +947,38 @@ class Buy
 
         if ($body) {
 
-            $head = array('名称', '单价', '数量', '状态');
-
-            $d = array
-            (
-                '合计',
-                round($body_total['price'], 2),
-                $body_total['num'],
-                '-'
-            );
+            if ($refund_body_total['price']) {
+                $body_total['set_price'] = $body_total['price'] - $refund_body_total['price'];
+            }
+            if ($refund_body_total['num']) {
+                $body_total['set_num'] = $body_total['num'] - $refund_body_total['num'];
+            }
 
             if ($type == 3) {
-                unset($head[1]);
-                unset($d[1]);
+                unset($body_total['price']);
+                unset($body_total['set_price']);
             }
-            $body[] = $d;
-
-
-            $html .= '<div class="layui-card"><div class="layui-card-header">商品清单</div><div class="layui-card-body" style="max-heights: 500px;overflow: auto;">' . $this->table($head, $body) . '</div></div>';
+            
+            $result['商品清单'] = array
+            (
+                'type' => 'list',
+                'content' => $body,
+                'total' => $body_total,
+            );
         }
 
         if ($refund_body) {
 
-            $head = array('名称', '单价', '数量', '状态');
-
-            $d = array
-            (
-                '合计',
-                round($refund_body_total['price'], 2),
-                $refund_body_total['num'],
-                '-'
-            );
             if ($type == 3) {
-                unset($head[1]);
-                unset($d[1]);
+                unset($refund_body_total['price']);
             }
-            $refund_body[] = $d;
 
-            $html .= '<div class="layui-card"><div class="layui-card-header">缺货与报损商品</div><div class="layui-card-body" style="max-heights: 300px;overflow: auto;">' . $this->table($head, $refund_body) . '</div></div>';
+            $result['缺货与报损商品'] = array
+            (
+                'type' => 'list',
+                'content' => $refund_body,
+                'total' => $refund_body_total,
+            );
         }
 
         if ($cash_type == 1) {
@@ -948,48 +1037,25 @@ class Buy
                 $body[] = $d;
             }
 
-            $html .= '<div class="layui-card"><div class="layui-card-header">对账清单</div><div class="layui-card-body" style="max-heights: 500px;overflow: auto;">' . $this->table($head, $body)  . '</div></div>';
+            $result['对账清单'] = array
+            (
+                'type' => 'table',
+                'content' => array
+                (
+                    'head' => $head,
+                    'body' => $body,
+                )
+            );
                 
         }
 
-        $html .= '</div>';
-
-        return '<div class="layui-card-body">' . $html . '</div>';
-    }
-
-    private function table($head, $data)
-    {
-        $html = '';
-        if ($head) {
-            $html = '<table class="layui-table">';
-
-            $html .= '<thead><tr>';
-            foreach ($head as $k => $v) {
-                $html .= '<th>'.$v.'</th>';
-            }
-            $html .= '</tr></thead>';
-
-            $html .= '<tbody>';
-            foreach ($data as $k => $v) {
-                $html .= '<tr>';
-                foreach ($v as $k1 => $v1) {
-                    $html .= '<td>'.$v1.'</td>';
-                }
-                $html .= '</tr>';
-            }
-
-            $html .= '</tbody>';
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => $button,
+        );
+        $html = Dever::show($head, $result);
 
-            $html .= '</table>';
-        } else {
-            foreach ($data as $k => $v) {
-                $html .= '';
-                foreach ($v as $k1 => $v1) {
-                    $html .= $v1 . '&nbsp;&nbsp;&nbsp;&nbsp;';
-                }
-                $html .= '';
-            }
-        }
         return $html;
     }
 

+ 71 - 134
app/mshop/lib/Out.php

@@ -172,7 +172,7 @@ class Out
             $state = Dever::db('shop/out_order')->update($where);
         }
 
-        return 'ok';
+        return 'reload';
     }
 
     # 取消出库单
@@ -235,93 +235,77 @@ class Out
 
         $cdate = date('Y-m-d H:i', $info['cdate']);
         
-        $html = '<div class="layui-col-md12"><div class="layui-card"><div class="layui-card-header">基本信息</div><div class="layui-card-body">';
-        $html .= '<table class="layui-table"><thead><tr><th style="width:20%">项目</th><th style="width:80%">详情</th></tr> </thead><tbody>';
-
-        $html .= '<tr>
-          <td>订单号</td>
-          <td>'.$this->table(false, array($info['order_num'])).'</td>
-
-        </tr>';
-
-        $html .= '<tr>
-          <td>出库单状态</td>
-          <td>'.$this->table(false, array($status)).'</td>
-
-        </tr>';
-
-        $html .= '<tr>
-          <td>填单时间</td>
-          <td>'.$this->table(false, array($cdate)).'</td>
-
-        </tr>';
-
         if ($info['type'] == 1) {
             $type_info = Dever::db('shop/info')->find($info['type_id']);
             $member = Dever::db('shop/member')->find($info['member_id']);
+            $name = '门店名称';
         } elseif ($info['type'] == 2) {
             $type_info = Dever::db('store/info')->find($info['type_id']);
             $member = Dever::db('store/member')->find($info['member_id']);
+            $name = '仓库名称';
         }
 
-        if ($type == 1) {
-            $html .= '<tr>
-              <td>来源信息</td>
-              <td>'.$this->table(false, array(array($type_info['name']  . '' . $type_info['truename'] . '' . $type_info['mobile'] . '' . $type_info['address']))).'</td>
-
-            </tr>';
-        }
-
-        $html .= '<tr>
-              <td>操作人</td>
-              <td>'.$this->table(false, array($member['name'])).'</td>
-
-            </tr>';
-
-        $html .= '<tr>
-          <td>出库类别</td>
-          <td>'.$this->table(false, array($out_type)).'</td>
-
-        </tr>';
-        
-        if ($info['info']) {
-            $html .= '<tr>
-              <td>订单备注</td>
-              <td>'.$this->table(false, array(array($info['info']))).'</td>
-
-            </tr>';
-        }
+        $result = array();
 
+        $result[$info['order_num']] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array($name, $type_info['name']),
+                    array('出库单状态', $status),
+                    array('填单时间', $cdate),
+                    
+                ),
+                
+                array
+                (
+                    array('填单人', $member['name']),
+                    array('出库类别', $out_type),
+                    array('原因备注', $info['info']),
+                ),
+            )
+        );
+
+        $button = array();
         if ($type == 2) {
             $config = Dever::load('store/admin/auth.config');
-            $button = array();
             if ($info['status'] == 1) {
-                $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[] = array
+                (
+                    'type' => 'action',
+                    'link' => Dever::url('admin/out.cancel?order_id='.$info['id'], 'store'),
+                    'name' => '取消',
+                );
             }
-            $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>';
-            $html .= '<tr>
-                  <td>功能按钮</td>
-                  <td>'.$this->table(false, array($button)).'</td>
+            
+            $button[] = array
+            (
+                'type' => 'link',
+                'link' => Dever::url('admin/out.print?id=' . $info['id'] . '&type=2', 'store'),
+                'name' => '打印出库单',
+            );
+
+            $button[] = array
+            (
+                'type' => 'alert',
+                'content' => $config['phone'],
+                'name' => '联系平台',
+            );
 
-                </tr>';
         } elseif ($info['status'] == 1) {
-            $button = array();
-            $url = Dever::url('lib/out.yes?id='.$info['type_id'].'&order_id='.$info['id'], 'mshop');
-            $button[] = '&nbsp;&nbsp;<a href="javascript:;" onclick="load(\''.$url.'\')"><button type="button" class="layui-btn layui-btn-primary">审核</button></a>';
-            $html .= '<tr>
-                  <td>功能按钮</td>
-                  <td>'.$this->table(false, array($button)).'</td>
-
-                </tr>';
+            
+            $button[] = array
+            (
+                'type' => 'action',
+                'link' => Dever::url('lib/out.yes?id='.$info['type_id'].'&order_id='.$info['id'], 'mshop'),
+                'name' => '审核',
+            );
         }
 
-        $html .= '</tbody></table></div></div>';
-
         $body = array();
         $body_total = array();
         $body_total['price'] = 0;
@@ -341,13 +325,15 @@ class Out
 
             $d = array
             (
-                $goods_info['name'],
-                $sku,
-                $v['price'],
-                $v['num'],
+                'pic' => $goods_info['cover'],
+                'name' => $goods_info['name'],
+                'sku' => $sku,
+                'price' => $v['price'],
+                'num' => $v['num'],
             );
+
             if ($type == 2) {
-                unset($d[2]);
+                unset($d['price']);
             }
             $body[] = $d;
             $price = $v['price']*$v['num'];
@@ -357,70 +343,21 @@ class Out
 
         if ($body) {
 
-            $head = array('商品名称', '商品属性', '商品单价', '商品数量');
-
-            $d = array
+            $result['出库商品清单'] = array
             (
-                '合计',
-                '-',
-                round($body_total['price'], 2),
-                $body_total['num'],
-
+                'type' => 'list',
+                'content' => $body,
+                'total' => $body_total,
             );
-
-            if ($type == 2) {
-                unset($head[2]);
-                unset($d[2]);
-            }
-            $body[] = $d;
-
-
-            $html .= '<div class="layui-card"><div class="layui-card-header">商品清单</div><div class="layui-card-body" style="max-heights: 500px;overflow: auto;">' . $this->table($head, $body) . '</div></div>';
         }
 
-        $html .= '</div>';
-
-        return '<div class="layui-card-body">' . $html . '</div>';
-    }
-
-    private function table($head, $data)
-    {
-        $html = '';
-        if ($head) {
-            $html = '<table class="layui-table">';
-
-            $html .= '<thead><tr>';
-            foreach ($head as $k => $v) {
-                $html .= '<th>'.$v.'</th>';
-            }
-            $html .= '</tr></thead>';
-
-            $html .= '<tbody>';
-            foreach ($data as $k => $v) {
-                $html .= '<tr>';
-                foreach ($v as $k1 => $v1) {
-                    $html .= '<td>'.$v1.'</td>';
-                }
-                $html .= '</tr>';
-            }
-
-            $html .= '</tbody>';
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => $button,
+        );
+        $html = Dever::show($head, $result);
 
-            $html .= '</table>';
-        } else {
-            foreach ($data as $k => $v) {
-                $html .= '';
-                if (is_array($v)) {
-                    foreach ($v as $k1 => $v1) {
-                        $html .= $v1 . '&nbsp;&nbsp;&nbsp;&nbsp;';
-                    }
-                } else {
-                    $html .= $v . '&nbsp;&nbsp;&nbsp;&nbsp;';
-                }
-                
-                $html .= '';
-            }
-        }
         return $html;
     }
 

+ 3 - 2
app/shop/assets/manage/html/out_order_goods.html

@@ -1,4 +1,4 @@
-</form>
+
 <form class="layui-form form10" action="" target="f10" method="post">
 <iframe id="f10" name="f10" style="display:none;"></iframe>
 <div class="layui-form-item" id="show">
@@ -23,4 +23,5 @@
         </tr>
       </tbody>
     </table>
-</div>
+</div>
+</form>

+ 18 - 2
app/shop/database/buy_order.php

@@ -9,8 +9,8 @@ $status = array
     5 => '已完成',
     6 => '已完成(有退款)',
     7 => '已取消',
-    8 => '已取消',
-    11 => '已取消',
+    8 => '已退款',
+    11 => '已过期',
 );
 
 $refund_status = array
@@ -379,5 +379,21 @@ return array
             'type' => 'one',
             'col' => 'sum(num) as total',
         ),
+
+        # 获取提交订单超过12个小时
+        'getDataByTime' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'cdate' => array('yes', '<='),
+                'status' => 'yes',
+                'notice' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
     ),
 );

+ 2 - 1
app/shop/database/out_order.php

@@ -223,7 +223,8 @@ return array
         'list_button' => array(
             //'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin', '{status} == 2'),
             //'delete' => array('删除', '', '{status} == 1'),
-            'fast_list' => array('查看详情', '"out_order_goods&project=shop&order_id={id}&page_type=1"'),
+            //'fast_list' => array('查看详情', '"out_order_goods&project=shop&order_id={id}&page_type=1"'),
+            'list' => array('查看详情', '"out_order_goods&project=shop&order_id={id}&page_type=1"'),
 
             'oper'  => array('审核', '"mshop/lib/out.yes?id={type_id}&order_id={id}"', '{status} == 1 && {type} == 2'),
         ),

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

@@ -119,7 +119,7 @@ return array
     (
         'insert' => false,
         'delete' => false,
-        'page_list_table' => 'out_order_goods',
+        'page_list' => 'out_order_goods',
     ),
 
     'request' => array

+ 13 - 0
app/shop/database/sell_order.php

@@ -34,6 +34,19 @@ $status = array
     11 => '已取消',//已过期
 );
 
+$status_manage = array
+(
+    1 => '待支付',
+    2 => '待处理',
+    3 => '处理中',
+    4 => '待收货确认',
+    5 => '已完成',
+    6 => '已完成(有退款)',
+    7 => '已取消',
+    8 => '已退款',//已退款
+    11 => '已过期',//已过期
+);
+
 //1待支付2支付成功3处理中4待确认5已完成6已完成(有退款)7已取消8已退款11已过期
 
 $refund_status = array

+ 19 - 0
app/shop/lib/Cron.php

@@ -115,6 +115,25 @@ class Cron
         }
     }
 
+    /**
+     * 处理待支付订单提醒
+     *
+     * @return mixed
+     */
+    public function buy_order_api()
+    {
+        $time = time();
+        $where['status'] = 1;
+        $where['cdate'] = $time - 7200;
+        $order = Dever::db('shop/buy_order')->getDataByTime($where);
+
+        if ($order) {
+            foreach ($order as $k => $v) {
+                Dever::db('shop/buy_order')->update(array('where_id' => $v['id'], 'status' => 11));
+            }
+        }
+    }
+
     /**
      * 处理销售数据 生成每天的销量统计
      *

+ 7 - 4
app/shop/lib/Info.php

@@ -239,7 +239,7 @@ class Info
     }
 
     # 获取库存
-    public function getGoodsInfo($shop_id, $info, $sku_id = false, $attr = true)
+    public function getGoodsInfo($shop_id, $info, $sku_id = false, $attr = true, $check = true)
     {
         $where['shop_id'] = $shop_id;
         $where['goods_id'] = isset($info['goods_id']) ? $info['goods_id'] : $info;
@@ -247,10 +247,13 @@ class Info
             $where['sku_id'] = $sku_id;
         }
         
-        $other = Dever::db('shop/goods_sku')->getData($where);
-        if (!$other) {
-            return false;
+        if ($check) {
+            $other = Dever::db('shop/goods_sku')->getData($where);
+            if (!$other) {
+                return false;
+            }
         }
+        
         $data = Dever::load('goods/lib/info')->getInfo($info, $attr, array($other, array('total')));
 
         if($data) {

+ 3 - 0
app/shop/lib/Refund.php

@@ -314,6 +314,9 @@ class Refund
         $data = Dever::load($this->lib)->set($type, 1)->getView($id, $order_id, false);
         $info = Dever::db($this->goods_table)->find(array('id' => $order_goods_id, 'order_id' => $data['id'], 'status' => 1));
         if ($info) {
+            if ($type > 10) {
+                $info['price'] = $info['p_price'];
+            }
         	if (isset($info['coupon_cash']) && $info['coupon_cash']) {
         		$info['tui_price'] = ($info['price'] * $info['num']) - $info['coupon_cash'];
         	} else {

+ 129 - 59
app/shop/lib/Sell.php

@@ -1001,45 +1001,76 @@ class Sell
             $user['truename'] = $user['username'];
         }
 
+        if (!$info['coupon_cash']) {
+            $info['coupon_cash'] = 0;
+        }
+
+        if (!$info['kou_cash']) {
+            $info['kou_cash'] = 0;
+        }
+
+        if (!$info['ps_cash']) {
+            $info['ps_cash'] = 0;
+        }
+
         if ($tk && $tk['process'] == 1) {
             $status = '申请' . $tk_status[$tk['status']];
             $process = $tk_process[$tk['process']];
             $process = '';
         }
 
-        $time = array('下单时间:' . $cdate);
+        $time = array();
+        $time[] = array('下单时间', $cdate);
 
         if ($opertime) {
             if ($info['status'] == 2) {
-                $time[] = '通知时间:' . $opertime;
+                $time[] = array('通知时间', $opertime);
             }
             if ($info['status'] == 7) {
-                $time[] = '取消时间:' . $opertime;
+                $time[] = array('取消时间:', $opertime);
             }
         }
 
         if ($fdate) {
-            $time[] = '完成时间:' . $fdate;
+            $time[] = array('完成时间:', $fdate);
         }
 
         $result = array();
 
-        $result['基本信息'] = array
+        $result[$info['order_num']] = array
         (
-            'head' => array('项目', '详情'),
-            'body' => array
+            'type' => 'info',
+            'content' => array
             (
-                array('订单信息', array('订单号:' . $info['order_num'], '金额:' . $info['price'], '数量:' . $info['num'], '状态:' . $status, '支付方式:' . $config['pay_method'][$info['pay_method']], '配送方式:' . $config['method'][$info['method']])),
-
-                array('订单时间', $time),
-
-                array('门店信息', array('门店名称:' . $shop['name'], '联系人:' . $shop['truename'], '联系电话:' . $shop['mobile'])),
+                array
+                (
+                    array('订单状态', $status),
+                    array('支付方式', $config['pay_method'][$info['pay_method']]),
+                    array('配送方式', $config['method'][$info['method']]),
+                ),
+                
+                array
+                (
+                    array('门店名称', $shop['name']),
+                    array('联系人', $shop['truename']),
+                    array('联系电话', $shop['mobile']),
+                ),
 
-                array('用户信息', array('昵称:' . $user['username'], '联系电话:' . $info['mobile'])),
+                array
+                (
+                    array('下单用户', $user['username']),
+                    array('联系电话', $info['mobile']),
+                    array('订单备注', $info['info']),
+                ),
 
-                array('订单备注', $info['info']),
+                array
+                (
+                    array('优惠券满减', '¥ ' . $info['coupon_cash']),
+                    array('抹零', '¥ ' . $info['kou_cash']),
+                    array('配送费', '¥ ' . $info['ps_cash']),
+                ),
 
-                array('其他信息', array('优惠券满减:' . $info['coupon_cash'], '抹零:' . $info['kou_cash'], '配送费:' . $info['ps_cash'])),
+                $time,
             )
         );
 
@@ -1047,23 +1078,52 @@ class Sell
             $address = Dever::load('passport/address')->getOne($info['uid'], $info['address_id']);
 
             if ($address) {
+
                 $result['收货地址'] = array
                 (
-                    'head' => array('地址', '门牌号', '姓名', '手机号'),
-                    'body' => array($address['address'], $address['house_number'], $address['contact'], $address['mobile'])
+                    'type' => 'info',
+                    'content' => array
+                    (
+                        array
+                        (
+                            array('联系人', $address['contact']),
+                            array('联系电话', $address['mobile']),
+                        ),
+
+                        array
+                        (
+                            array('收货地址', $address['address']),
+                            array('门牌号', $address['house_number']),
+                        ),
+                    ),
                 );
             }
-            
         }
 
+        
         if ($info['invoice_id'] > 0) {
             $invoice = Dever::load('passport/invoice')->getOne($info['uid'], $info['invoice_id']);
 
             if ($invoice) {
+
                 $result['发票信息'] = array
                 (
-                    'head' => array('发票类型', '抬头', '税号','手机号', '邮箱'),
-                    'body' => array($invoice['title_type_name'], $invoice['title'], $invoice['number'], $invoice['mobile'], $invoice['email'])
+                    'type' => 'info',
+                    'content' => array
+                    (
+                        array
+                        (
+                            array('发票类型', $invoice['title_type_name']),
+                            array('抬头', $invoice['title']),
+                            array('税号', $invoice['number']),
+                        ),
+
+                        array
+                        (
+                            array('手机号', $invoice['mobile']),
+                            array('邮箱', $invoice['email']),
+                        ),
+                    ),
                 );
             }
         }
@@ -1075,10 +1135,25 @@ class Sell
 
         if ($info['refund_cash'] > 0 && $tk) {
             $process = $tk_process[$tk['process']];
+            $tk['cdate'] = date('Y-m-d H:i', $tk['cdate']);
             $result['退款信息'] = array
             (
-                'head' => array('退款金额', '数量', '退款原因', '退款进度'),
-                'body' => array($info['refund_cash'], $info['num'], $tk['desc'], $process)
+                'type' => 'info',
+                'content' => array
+                (
+                    array
+                    (
+                        array('退款金额', $info['refund_cash']),
+                        array('数量', $info['num']),
+                        array('退款进度', $process),
+                    ),
+
+                    array
+                    (
+                        array('申请时间', $tk['cdate']),
+                        array('退款原因', $tk['desc']),
+                    ),
+                ),
             );
         }
 
@@ -1108,27 +1183,24 @@ class Sell
                 $sku = '无';
             }
 
+            $d = array
+            (
+                'pic' => $goods_info['cover'],
+                'name' => $goods_info['name'],
+                'sku' => $sku,
+                'price' => $v['price'],
+                'num' => $v['num'],
+                'status' => $status,
+            );
+
             if ($tk && $v['status'] == 3) {
-                $refund_body[] = array
-                (
-                    $goods_info['name'],
-                    $sku,
-                    $v['price'],
-                    $v['num'],
-                    $tk_status[$tk['status']],
-                );
+                $d['status'] = $tk_status[$tk['status']];
+                $refund_body[] = $d;
                 $price = $v['price']*$v['num'];
                 $refund_body_total['price'] += $price;
                 $refund_body_total['num'] += $v['num'];
             } else {
-                $body[] = array
-                (
-                    $goods_info['name'],
-                    $sku,
-                    $v['price'],
-                    $v['num'],
-                    $status,
-                );
+                $body[] = $d;
                 $price = $v['price']*$v['num'];
                 $body_total['price'] += $price;
                 $body_total['num'] += $v['num'];
@@ -1136,39 +1208,37 @@ class Sell
         }
 
         if ($body) {
-            $body[] = array
-            (
-                '合计',
-                '-',
-                round($body_total['price'], 2),
-                $body_total['num'],
-                '-'
-            );
+            if ($refund_body_total['price']) {
+                $body_total['set_price'] = $body_total['price'] - $refund_body_total['price'];
+            }
+            if ($refund_body_total['num']) {
+                $body_total['set_num'] = $body_total['num'] - $refund_body_total['num'];
+            }
+
             $result['商品清单'] = array
             (
-                'head' => array('名称', '属性', '单价', '数量', '状态'),
-                'body' => $body,
+                'type' => 'list',
+                'content' => $body,
+                'total' => $body_total,
             );
         }
 
         if ($refund_body) {
-            $refund_body[] = array
-            (
-                '合计',
-                '-',
-                round($refund_body_total['price'], 2),
-                $refund_body_total['num'],
-                '-'
-            );
             $result['退款商品'] = array
             (
-                'head' => array('名称', '属性', '单价', '数量', '状态'),
-                'body' => $refund_body,
+                'type' => 'list',
+                'content' => $refund_body,
+                'total' => $refund_body_total,
             );
         }
         
 
-        $html = Dever::show($result);
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => array(),
+        );
+        $html = Dever::show($head, $result);
 
         return $html;
     }

+ 1 - 1
app/shop/src/Buy.php

@@ -85,7 +85,7 @@ class Buy extends Core
 			Dever::alert('错误的商品');
 		}
 
-		$this->data['goods'] = Dever::load('shop/lib/info')->getGoodsInfo($this->shop_id, $id);
+		$this->data['goods'] = Dever::load('shop/lib/info')->getGoodsInfo($this->shop_id, $id, false, true, false);
 
 		//$this->data['shop'] = $this->shop;
 

+ 16 - 0
app/store/admin/Order.php

@@ -128,6 +128,9 @@ class Order extends Core
 
     	# 发货
     	$data['send'] = Dever::url('admin/order.send', 'store');
+
+        # 退款
+        $data['tui'] = Dever::url('lib/buy.refund_apply_info_one_commit?json=1', 'mshop');
     	return $data;
     }
 
@@ -166,4 +169,17 @@ class Order extends Core
     {
         return Dever::load('mshop/lib/buy')->printer($this->user);
     }
+
+    # 获取报损信息
+    public function refund()
+    {
+        $data = Dever::load('mshop/lib/buy')->refund_apply_info_one_info();
+
+        if (isset($data['num'])) {
+            $data['tui_price_info'] = 'x' . $data['num'];
+        } else {
+            $data['tui_price_info'] = '0';
+        }
+        return $data;
+    }
 }

File diff suppressed because it is too large
+ 19 - 0
app/store/assets/pc/html/order_tui.html


+ 3 - 3
app/store/assets/pc/html/order_view.html

@@ -86,18 +86,18 @@ function tui(goods_id, order_id, source_id, status, url)
 {
     var index = layer.confirm('确定进行此项操作吗?', function()
     {
-        $.getJSON(url, {order_goods_id:goods_id,order_id:order_id,type_id:source_id,type:13,status:status,desc:'仓库上报'}, function(t)
+        $.getJSON(url, {order_goods_id:goods_id,order_id:order_id,type_id:source_id,type:12,status:status,desc:'仓库上报'}, function(t)
         {
             msg(t);
         })
     })
 }
 
-function cancel(order_id, source_id, url)
+function cancel(url)
 {
     var index = layer.confirm('确定要取消该订单吗?', function()
     {
-        $.getJSON(url, {order_id:order_id,type_id:source_id,type:13,desc:'仓库上报'}, function(t)
+        $.getJSON(url, {type:12,desc:'仓库上报'}, function(t)
         {
             msg(t);
         })

+ 18 - 0
app/store/template/pc/order_tui.php

@@ -0,0 +1,18 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| home
+|--------------------------------------------------------------------------
+*/
+$view
+
+# 定义名称
+->fetch('.form1@action', 'store/admin/order.getConfig#tui') 
+->fetch('#order_id@value', '<{Dever::input("order_id")}>')
+->fetch('#order_goods_id@value', '<{Dever::input("order_goods_id")}>')
+->fetch('#type@value', '<{Dever::input("type")}>') 
+->fetch('#type_id@value', '<{Dever::input("type_id")}>') 
+->fetch('#cash', 'store/admin/order.refund#tui_price_info') 
+
+# display
+->display();

Some files were not shown because too many files changed in this diff