Your Name 2 tahun lalu
induk
melakukan
f5e836912c

+ 38 - 0
app/card/database/code.php

@@ -306,5 +306,43 @@ return array
                 'use_cash' => array('yes', '-='),
             ),
         ),
+        #兑换的数量
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'card_id' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
+        'getDuiprice' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'card_id' => 'yes',
+                'status' => array('yes','in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(total_cash) as total',
+        ),
+        #已使用的面值
+        'getDprice' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'card_id' => 'yes',
+                // 'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(use_cash) as total',
+        ),
     ),
 );

+ 36 - 17
app/card/database/info.php

@@ -37,7 +37,20 @@ $shop_set = array
 (
     1 => '体验店无使用限制',
 );
-
+$insert = false;
+$edit = false;
+$delete = false;
+# 权限设置 1是卡号列表、2是礼品卡使用统计
+$search_auth = Dever::input('search_option_dever_auth', 1);
+$list_button = array();
+if($search_auth == 1){
+    $insert = true;
+    $edit = true;
+    $list_button['fast'] = array('生成卡号', '"add&where_id=1&search_option_card_id={id}"', '{status} == 1');
+    $list_button['list1'] = array('卡号列表', '"code&search_option_card_id={id}&oper_table=info"');
+    $list_button['location1'] = array('可用商品设置', Dever::url('lib/goods_set.home', 'card'));
+    
+}
 return array
 (
     # 表名
@@ -82,6 +95,7 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $type,
+            'search'    => $search_auth == 2 ? 'select' : '',
             'list'      => true,
         ),
 
@@ -107,8 +121,8 @@ return array
             'desc'      => '面值',
             'match'     => 'is_numeric',
             'update'    => 'text',
-            'list_name' => '面值/售价',  
-            'list'      => '"{value}/{price}"',
+            'list_name' => $search_auth == 1 ? '面值/售价' : '礼品卡面值',  
+            'list'      => $search_auth == 1 ? '"{value}/{price}"' : true,
         ),
 
         'price'        => array
@@ -142,6 +156,7 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $create_type,
+            'search'    => $search_auth == 2 ? 'select' : '',
             'list'      => true,
         ),
 
@@ -177,8 +192,8 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'select',
             'option'    => $card_type,
-            'list_name' => '数量',
-            'list'      => 'Dever::load("card/lib/manage.getNum", "{id}")',
+            'list_name' => $search_auth == 1 ? '数量' : '兑换/发放数量',
+            'list'      => $search_auth == 1 ? 'Dever::load("card/lib/manage.getNum", "{id}")' : 'Dever::load("card/lib/manage.getCardNum", "{id}")',
         ),
 
         'card_prefix'        => array
@@ -220,8 +235,9 @@ return array
             'match'     => 'is_numeric',
             //'update'  => 'select',
             'option'    => $status,
-            'search'    => 'select',
-            'list'      => true,
+            'search'    => $search_auth == 1 ? 'select' : '',
+            'list_name' => $search_auth == 1 ? '状态' :'已兑换面值',
+            'list'      => $search_auth == 1 ? true : 'Dever::load("card/lib/manage.getDprice",{id})',
             'edit'      => true,
         ),
 
@@ -234,6 +250,8 @@ return array
             'match'     => 'is_string',
             'update'    => 'textarea',
             'key'       => '1',
+            'list_name' => $search_auth == 2 ? '已使用面值' :'',
+            'list'      => $search_auth == 1 ? false : 'Dever::load("card/lib/manage.getDprice",{id},1)',
         ),
 
         'reorder'       => array
@@ -245,7 +263,8 @@ return array
             'match'     => 'option',
             'update'  => 'text',
             'search'    => 'order',
-            'list'      => true,
+            'list_name' => $search_auth == 1 ? '排序' :'',
+            'list'      => $search_auth == 1 ? true : false,
             'order'     => 'desc',
             'edit'      => true,
         ),
@@ -257,6 +276,8 @@ return array
             'default'   => '1',
             'desc'      => '请选择状态',
             'match'     => 'is_numeric',
+            'list_name' => $search_auth == 1 ? '' :'未兑换面值',
+            'list'      => $search_auth == 1 ? false : 'Dever::load("card/lib/manage.getDprice",{id},2)',
         ),
         
         'cdate'     => array
@@ -267,20 +288,18 @@ return array
             'desc'      => '',
             # 只有insert时才生效
             'insert'    => true,
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'search'    => $search_auth == 2 ? 'date' : false,
+            'list'      => $search_auth == 1 ? 'date("Y-m-d H:i:s", {cdate})' : false,
         ),
     ),
 
     'manage' => array
     (
-    	'list_button' => array
-        (
-            'fast' => array('生成卡号', '"add&where_id=1&search_option_card_id={id}"', '{status} == 1'),
-
-            'list1' => array('卡号列表', '"code&search_option_card_id={id}&oper_table=info"'),
-
-            'location1' => array('可用商品设置', Dever::url('lib/goods_set.home', 'card')),
-        ),
+        'insert' => $insert,
+        'edit' => $edit,
+        'delete' => $delete,
+    	'list_button' => $list_button,
+       
     ),
 
     'request' => array

+ 46 - 1
app/card/lib/Manage.php

@@ -36,7 +36,52 @@ class Manage
         $where['card_id'] = $id;
         return Dever::db('card/code')->total($where);
     }
-
+    public function getCardNum($id)
+    {
+        $where['card_id'] = $id;
+        $html = array();
+        #兑换的数量
+        $dnum = Dever::db('card/code')->getNum(array('card_id'=>$id,'status'=>3,'state'=>1));
+        #发放的数量
+        $num = Dever::db('card/code')->total($where);
+        return $dnum.'/'.$num;
+    }
+    public function getDprice($id,$type=false){
+        $card = Dever::db('card/info')->find($id);
+        #已兑换的面值
+        $dui_total = 0;
+        if($card['create_type'] != 3){
+            $dnum = Dever::db('card/code')->getNum(array('card_id'=>$id,'status'=>3,'state'=>1));
+            $dui_total = $dnum*$card['value'];
+            
+        }else{
+            $dui = Dever::db('card/code')->getDuiprice(array('card_id'=>$id,'status'=>3,'state'=>1));
+            $dui_total = $dui['total'];
+        }
+        if(!$type){
+            return $dui_total;
+        }
+        #已使用的面值
+        $info = Dever::db('card/code')->getDprice(array('card_id'=>$id,'state'=>1));
+        $use_total = sprintf ('%01.2f',$info['total']);
+        if($type==1){
+            return $use_total;
+        }
+        #未兑换的面值
+         $wdui_total = 0;
+        if($card['create_type'] != 3){
+            $where['card_id'] = $id;
+            $num = Dever::db('card/code')->total($where);
+            $wdui_total = ($num-$dnum) *$card['value'];
+        }else{
+            $wdui = Dever::db('card/code')->getDuiprice(array('card_id'=>$id,'status'=>'1,2','state'=>1));
+            $wdui_total = $wdui['total'];
+        }
+        if($type == 2){
+            return $wdui_total;
+        }
+       
+    }
     /**
      * 显示用户信息
      *

+ 24 - 1
app/cash/database/order.php

@@ -373,7 +373,11 @@ return array
         'delete' => false,
         'edit' => false,
         'insert' => false,
-        'excel'	=> true,
+        // 'excel'	=> true,
+        'button' => array
+        (
+            '数据导出' => array('excel', 'cash/lib/order.out_order'),
+        ),
 
         'page_list' => 'order_list',
 
@@ -532,5 +536,24 @@ return array
             'type' => 'all',
             'col' => '*',
         ),
+        
+        'getExcel' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'pay_type' => 'yes',
+                'audit' => 'yes',
+                'jstype' => 'yes',
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*',
+        ),
     ),
 );

+ 93 - 0
app/cash/lib/Order.php

@@ -120,4 +120,97 @@ class Order
             return $this->getOrderId();
         }
     }
+    #导出Excel
+    public function out_order_api(){
+        $start = Dever::input('search_option_start_operdate');
+        $end = Dever::input('search_option_start_operdate');
+        $type = Dever::input('search_option_type');
+        $pay_type = Dever::input('search_option_pay_type');
+        $audit = Dever::input('search_option_audit');
+        $status = Dever::input('search_option_status');
+        $jstype = Dever::input('search_option_jstype');
+        $type_id = Dever::input('search_option_type_id');
+        $where = array();
+        if($start){
+            $where['start'] = $start;
+        }
+        if($end){
+            $where['end'] = $end;
+        }
+        if($type){
+            $where['type'] = $type;
+        }
+        if($pay_type){
+            $where['pay_type'] = $pay_type;
+        }
+        if($audit){
+            $where['audit'] = $audit;
+        }
+        if($status){
+            $where['status'] = $status;
+        }
+        if($jstype){
+            $where['jstype'] = $jstype;
+        }
+        if($type_id){
+            $where['type_id'] = $type_id;
+        }
+        $where['state'] = 1;
+        $data = Dever::db('cash/order')->getExcel($where);
+        $header = array('ID', '结算单号', '结算门店', '订货单编号', '数量', '结算金额', '结算类型', '入账状态', '审核状态', '支付类型', '结算时间','审核备注','生成时间');
+        $body = array();
+        foreach($data as $k => $v){
+            $type_info = Dever::db('shop/info')->find(array('id'=>$v['type_id']));
+            $config_jstype = Dever::db('cash/order')->config['config_jstype'];
+            if(isset($v['jstype']) && $v['jstype']){
+                $jstype = Dever::status($config_jstype,$v['jstype']);
+            }
+            
+            $config_status = Dever::db('cash/order')->config['config_status'];
+            if(isset($v['status']) && $v['status']){
+                $status = Dever::status($config_status,$v['status']);
+            }
+            $config_audit = Dever::db('cash/order')->config['config_audit'];
+            if(isset($v['audit']) && $v['audit']){
+                $audit = Dever::status($config_audit,$v['audit']);
+            }
+            if(isset($v['pay_type']) && $v['pay_type']){
+                if($v['pay_type'] == 1){
+                    $pay_type_name = '在线支付';
+                }elseif($v['pay_type'] == 2){
+                    $pay_type_name = '礼品卡支付';
+                }else{
+                    $pay_type_name = '钱包支付';
+                }
+            }
+            $operdate = '-';
+            if(isset($v['operdate']) && $v['operdate']){
+                $operdate = date('Y-m-d H:i',$v['operdate']);
+            }
+            $cdate = '-';
+            if(isset($v['cdate']) && $v['cdate']){
+                $cdate = date('Y-m-d H:i',$v['cdate']);
+            }
+            
+            $d = array
+            (
+                $v['id'],
+                $v['order_num'],
+                $type_info['name'],
+                $v['source_order_num'],
+                $v['num'],
+                $v['cash'],
+                $jstype,
+                $status,
+                $audit,
+                $pay_type_name,
+                $operdate,
+                $v['desc'],
+                $cdate,
+            );
+            $body[] = $d;
+        }
+        $file = '结算单数据列表';
+        Dever::excelExport($body, $header, $file);
+    }
 }