Your Name %!s(int64=3) %!d(string=hai) anos
pai
achega
5e39c63a90

+ 13 - 0
learn/active/database/code.php

@@ -349,5 +349,18 @@ return array
             // 'order' => array('cdate' => 'desc'),
             'col' => '*',
         ),
+        'getExcel' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'count',
+            // 'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
     ),
 );

+ 14 - 0
learn/active/database/info.php

@@ -474,6 +474,20 @@ return array
             'tab'       => 3,
         ),
 
+        'off_type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '已核销是否可以退款',
+            'default'   => '1',
+            'desc'      => '是否可以退款',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $refund_type,
+            // 'search'    => 'select',
+            // 'list'      => true,
+            'tab'       => 3,
+        ),
+
         'sit_type'        => array
         (
             'type'      => 'tinyint-1',

+ 173 - 0
learn/active/database/info_refund_log.php

@@ -0,0 +1,173 @@
+<?php
+$status = array
+(
+    1 => '退款失败',
+    2 => '退款成功',
+);
+return array
+(
+    # 表名
+    'name' => 'info_refund_log',
+    # 显示给用户看的名称
+    'lang' => '活动退款',
+    # 后台菜单排序
+    'order' => 2,
+    'menu' => false,
+    'start' => array
+    (
+    	'insert' => 'active/lib/manage.insertInfoRefundLog',
+    ),
+    'end' => array 
+    (
+    	'insert' => 'active/lib/manage.updateInfoRefundLog',
+    	// 'update' => 'active/lib/manage.updateInfoRefund',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单id',
+            'default'   => '-1',
+            'desc'      => '订单id',
+            'match'     => 'is_string',
+            'value'     => Dever::input('search_option_order_id'),
+            'update'    => 'hidden',
+            // 'search'    => 'text',
+            // 'list'      => "Dever::load('active/lib/manage.active',{active_id})",
+        ),
+
+        'code_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单id',
+            'default'   => '-1',
+            'desc'      => '订单id',
+            'match'     => 'is_string',
+            'value'     => Dever::input('search_option_code_id'),
+            'update'    => 'hidden',
+            // 'search'    => 'text',
+            // 'list'      => "Dever::load('active/lib/manage.active',{active_id})",
+        ),
+
+        // 'num'      => array
+        // (
+        //     'type'      => 'int-11',
+        //     'name'      => '退款数量-单位:张',
+        //     'default'   => '0',
+        //     'desc'      => '限购数量',
+        //     'match'     => 'option',
+        //     'update'    => 'text',
+        //     // 'search'    => 'fulltext',
+        //     // 'list'      => true,
+        // ),
+
+        'price'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '退款票价-单位:元',
+            'default'   => '0',
+            'desc'      => '票价-单位:元',
+            'match'     => 'option',
+            'update'    => 'text',
+            'value'     => Dever::input('search_option_price'),
+            // 'list'      => $search_auth == 1 ? true : false,
+            // 'list_order' => '3',
+            // 'tab'       => 2,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '退款状态',
+            'default'   => '1',
+            'desc'      => '退款状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            // 'list'      => true,
+        ),
+
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款操作人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '退款操作人',
+            // 'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款日期',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'day',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list_order' => 5,
+        ),
+    ),
+
+    'manage' => array
+    (
+    	'insert' => false,
+        'delete' => false,
+        'edit' => false,
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'join_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'state' => 1,
+                'status' => 2,
+            ),
+            'type' => 'one',
+            'order' => array('cdate' => 'desc'),
+            'col' => 'sum(num) as num',
+        ),
+    ),
+);

+ 66 - 7
learn/active/lib/Manage.php

@@ -370,7 +370,8 @@ Class Manage
                 );
             }
         }
-        if ($info['status'] > 1 && $no_code > 0 && $info['status'] != 3 && time()<$active['act_start'] && $active['refund_type'] == 2) {
+        if ($info['status'] > 1 && $no_code > 0 && $info['status'] != 3  && $active['refund_type'] == 2) {
+            // && time()<$active['act_start']
             if (Dever::load('manage/auth')->checkFunc('active.order', 'editrefund1', '未使用退款')) {
                 $purl = Dever::url('project/database/update?project=active&table=info_refund&search_option_order_id='.$info['id'].'&col=num,order_id', 'manage');
                 $button[] = array
@@ -438,10 +439,21 @@ Class Manage
                 }
                 $active = Dever::db('active/info')->find($v['active_id']);
                 $m = '';
-                if ($v['status'] == 1 && time()<$active['act_start'] && $active['refund_type'] == 2) {
-                    $url = Dever::url('lib/manage.setOrder&order_id=' . $v['order_id'].'&code_id='.$v['id'], 'active');
-                    $m = '<a href="javascript:;" onclick="load( \''.$url.'\')" class="layui-btn">退款</a>';
+                if ($v['status'] == 1 && $active['refund_type'] == 2 ) {
+                    // && time()<$active['act_start'] 
+                    if ($active['refund_type'] == 2) {
+                        if ($v['status']!=3) {
+                            $url = Dever::url('project/database/update?project=active&table=info_refund_log&search_option_price='.$active['price'].'&search_option_code_id='.$v['id'].'&search_option_order_id='.$v['id'].'&col=price,order_id,code_id', 'manage');
+                        }
+                    } else {
+                       if ($v['status']==1) {
+                            $url = Dever::url('project/database/update?project=active&table=info_refund_log&search_option_price='.$active['price'].'&search_option_code_id='.$v['id'].'&search_option_order_id='.$v['id'].'&col=price,order_id,code_id', 'manage');
+                        } 
+                    }
+                    // $url = Dever::url('lib/manage.setOrder&order_id=' . $v['order_id'].'&code_id='.$v['id'].'&col=price', 'active');
+                    $m = '<a href="javascript:;" onclick="fastEdit($(this), \''.$url.'\')" class="layui-btn">退款</a>';
                 }
+                
                 $d = array
                 (
                     $join_name,
@@ -468,6 +480,46 @@ Class Manage
             return array();
         }
     }
+    public function insertInfoRefundLog($id,$name,$data)
+    {
+        $price = Dever::param('price',$data);
+        $order_id = Dever::param('order_id',$data);
+        $code_id = Dever::param('code_id',$data);
+        $order = Dever::db('active/order')->find($order_id);
+        $active = Dever::db('active/info')->find($order['info_id']);
+        if (!$price) {
+            Dever::alert('退款金额不能为空');
+        }
+        if ($price > $active['price']) {
+            Dever::alert('退款金额大于购买金额');
+        }
+        $data = Dever::db('active/info_refund_log')->find(Array('order_id'=>$order_id,'code_id'=>$code_id));
+        if($data) {
+            Dever::alert('不可重复退款');
+        }
+    }
+    public function updateInfoRefundLog($id,$name,$data)
+    {
+        $price = Dever::param('price',$data);
+        $order_id = Dever::param('order_id',$data);
+        $code_id = Dever::param('code_id',$data);
+        $order = Dever::db('active/order')->find($order_id);
+        $where['order_id'] = $order_id;
+        $where['code_id'] = $code_id;
+        $where['price'] = $price;
+        $data = Dever::db('active/order')->find($order_id);
+        $ids = $this->common($data,3,false,false,$price);
+        if ($ids) {
+            Dever::db('active/info_refund_log')->insert($where);
+            $admin = Dever::load('manage/auth.info');
+            $w['where_id'] = $code_id;
+            $w['status'] = 3;
+            $w['offdate'] = time();
+            $w['audit_admin'] = $admin['id'];
+            Dever::db('active/code')->update($w);
+        }
+        return 'reload';
+    }
     public function setOrder_api($order_id,$code_id){
         $data = Dever::db('active/order')->find($order_id);
         $ids = $this->common($data,3);
@@ -482,13 +534,14 @@ Class Manage
         return 'reload';
     }
 
-    public function common($data,$type,$num=false,$refund_id=false){
+    public function common($data,$type,$num=false,$refund_id=false,$refund_price=false){
         Dever::config('base')->hook = true;
         $active = Dever::db('active/info')->find($data['active_id']);
         $info = Dever::db('active/info_refund')->state(array('order_id'=>$data['id']));
         if (time() > $active['act_start']) {
-            Dever::alert('活动已开始,不能退款');
+            // Dever::alert('活动已开始,不能退款');
         }
+        
         if ($type == 1) {
             $code = Dever::db('active/code')->find(array('order_id'=>$data['id']));
             if ($data['code_num'] > 0 || (isset($code) && $code)) {
@@ -506,9 +559,15 @@ Class Manage
         }
         if ($type == 3) {
             $refund_num = 1;
-            $price = $active['price'];
+            if ($refund_price) {
+                $price = $refund_price;
+            } else {
+                $price = $active['price'];
+            }
+            
         }
         
+        
         $param = array
         (
             'project_id' => 6,