Your Name 3 éve
szülő
commit
0d21e99331

+ 7 - 1
learn/active/database/code.php

@@ -45,7 +45,13 @@ return array
             'desc'      => '活动名称',
             'match'     => 'is_string',
             'update'    => 'hidden',
-            // 'search'    => 'text',
+             'search'    => array
+            (
+                'api' => 'active/info-getSearch',
+                'col' => 'col',
+                'result' => 'id',
+                'search' => 'active_id',
+            ),
             'list'      => "Dever::load('active/lib/manage.active#active_name',{active_id})",
         ),
 

+ 42 - 9
learn/active/database/info.php

@@ -21,6 +21,12 @@ $type = array
     2 => '活动门票',
 );
 
+$online = array
+(
+    1 => '发布',
+    2 => '未发布',
+);
+
 $cost_type = array
 (
     //1 => '押金报名',
@@ -55,10 +61,11 @@ if ($search_auth == 1) {
         $list_button['list1'] = array('自定义字段设置', '"info_field&search_option_active_id={id}&oper_table=info"');
     }
 } else {
-    // if (Dever::load('manage/auth')->checkFunc('active.info_1', 'editOff', '核销活动')) {
+    if (Dever::load('manage/auth')->checkFunc('active.info_1', 'editOff', '核销活动')) {
         // $button['核销活动'] = array('fast',1,'info_code');
-        $list_button['fast_add'] = array('核销活动', 'info_code&search_option_active_id={id}');
-    // }
+        $list_button['fast_add'] = array('手动核销', 'info_code&search_option_active_id={id}');
+        // $list_button['location'] = array('扫码核销',Dever::url('lib/manage.code','active'));
+    }
 }
 $off = function() use($search_auth)
 {
@@ -134,11 +141,11 @@ return array
         'banner'       => array
         (
             'type'      => 'text-255',
-            'name'      => '顶部banner',
+            'name'      => '详情顶部图片',
             'default'   => '',
-            'desc'      => '顶部banner',
+            'desc'      => '顶部图片',
             'match'     => 'is_string',
-            'update'    => 'images',
+            'update'    => 'image',
             'key'       => '1',
             // 'place'     => '759*562',
         ),
@@ -228,7 +235,7 @@ return array
             'update'    => 'radio',
             'option'    => $type,
             // 'search'    => 'select',
-            'list'      => $search_auth == 1 ? true : false,
+            // 'list'      => $search_auth == 1 ? true : false,
             'tab'       => 2,
         ),
 
@@ -246,6 +253,21 @@ return array
             'tab'       => 1,
         ),
 
+        'online'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $online,
+            // 'search'    => 'select',
+            'list'      => $search_auth == 1 ? true : false,
+            'edit'      => true,
+            'tab'       => 2,
+        ),
+
         'num'      => array
         (
             'type'      => 'int-11',
@@ -352,9 +374,9 @@ return array
         'cover'       => array
         (
             'type'      => 'text-255',
-            'name'      => '封面图',
+            'name'      => '列表封面图',
             'default'   => '',
-            'desc'      => '封面图',
+            'desc'      => '列表封面图',
             'match'     => 'option',
             'update'    => 'image',
             'key'       => '1',
@@ -510,12 +532,23 @@ return array
 
     'request' => array
     (
+        'getSearch' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'col' => array('yes-name', 'like'),
+            ),
+            'type' => 'all',
+            'col' => '*|id',
+        ),
         'getAll' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array
             (
                 'off_id' => array('yes','like'),
+                'online' => 1,
                 'state' => 1,
             ),
             'type' => 'all',

+ 4 - 1
learn/active/database/info_code.php

@@ -1,5 +1,8 @@
 <?php
-
+$active_id = Dever::input('search_option_active_id');
+if ($active_id) {
+    $info = Dever::load('active/lib/manage')->getInfoActive($active_id);
+}
 return array
 (
     # 表名

+ 8 - 2
learn/active/database/order.php

@@ -90,13 +90,19 @@ return array
         'uid'      => array
         (
             'type'      => 'int-11',
-            'name'      => '用户名称',
+            'name'      => '用户名称/手机号',
             'default'   => '-1',
             'desc'      => '用户名称',
             'match'     => 'is_string',
             // 'option'    => $user,
             // 'update'    => 'text',
-            // 'search'    => 'text',
+            'search'    => array
+            (
+                'api' => 'active/user-getSearch',
+                'col' => 'col',
+                'result' => 'id',
+                'search' => 'uid',
+            ),
             'list_name' => '用户信息',
             'list'      => 'Dever::load("active/lib/manage.user", {uid})',
         ),

+ 10 - 1
learn/active/lib/Active.php

@@ -150,9 +150,18 @@ class Active
 
         $order = Dever::db('active/order')->one(array('id' => $product_id, 'clear' => true));
         if ($order && $status == 2) {
-            $update['status'] = 2;
+        	$update['status'] = 2;
             $update['where_id'] = $order['id'];
             Dever::db('active/order')->update($update);
+        	$code = Dever::db('active/code')->find(array('join_uid'=>$order['uid'],'active_id'=>$order['active_id']));
+        	if (!$code) {
+        		$insert['join_uid'] = $order['uid'];
+        		$insert['active_id'] = $order['active_id'];
+        		$insert['buy_uid'] = $order['uid'];
+        		$insert['write_code'] = Dever::load('active/home')->getCode();
+        		Dever::db('active/code')->insert($insert);
+        		Dever::load('active/lib/manage')->upNum($order['id']);
+        	} 
         }
 
         return 'ok';

+ 82 - 0
learn/active/lib/Manage.php

@@ -543,4 +543,86 @@ Class Manage
         $w['where_id'] = $data['id'];
         Dever::db('active/order')->update($w);
     }
+
+    #扫码核销活动
+    public function code_api(){
+        $active_id = Dever::input('id');
+        if (!$active_id) {
+             return '活动id不存在';
+        }
+        $active = Dever::db('active/info')->find($active_id);
+        $config = Dever::db('active/info')->config['config_act_status'];
+        
+        $code = Dever::input('code');
+        if (!$code) {
+            $data = array();
+            $data['active_name'] = $active['name'];
+            $data['status'] = Dever::status($config,$active['act_status']);
+            $data['act_time'] = date('Y.m.d H:i:s',$active['act_start']).'~'.date('Y.m.d H:i:s',$active['act_end']);
+            $data['active_id'] = $active_id;
+            return Dever::render('off_code', $data);
+        }
+       
+        // print_R($code);die;
+        $data = Dever::db('active/code')->find(array('write_code'=>$code,'active_id'=>$active_id,'status'=>1));
+        if ($data) {
+            $data['active_name'] = $active['name'];
+            $data['status'] = Dever::status($config,$active['act_status']);
+            $data['act_time'] = date('Y.m.d H:i:s',$active['act_start']).'~'.date('Y.m.d H:i:s',$active['act_end']);
+            $join_user = Dever::db('active/user')->find($data['join_uid']);
+            $data['join_name'] = $join_user['name'];
+            $data['join_mobile'] = $join_user['mobile'];
+            $con = Dever::db('deploy/base-one');
+            if ($join_user['avatar']) {
+                $data['join_avatar'] = $join_user['avatar'];
+            } else {
+                $data['join_avatar'] = $con['avatar'];
+            }
+             
+            $buy_user = Dever::db('active/user')->find($data['buy_uid']);
+            $data['buy_name'] = $buy_user['name'];
+            $data['buy_mobile'] = $buy_user['mobile'];
+            $data['buy_avatar'] = '';
+            if ($buy_user['avatar']) {
+                $data['buy_avatar'] = $buy_user['avatar'];
+            } 
+            $member = Dever::load('active/lib/user')->agent($buy_user);
+            $data['role_name'] ='';
+            $data['title_name'] = '';
+            if ($member) {
+                $role = Dever::db('setting/role')->find($member['role']);
+                $title = Dever::db('setting/title')->find($member['title_id']);
+                $level = Dever::db('setting/level')->find($member['level_id']);
+                if ($role) {
+                    if (isset($level) && $level && isset($level['name']) && $level['name']) {
+                        $data['role_name'] = $role['name'] .'('.$level['name'].')';
+                    } else {
+                        $data['role_name'] = $role['name'];
+                    }
+                }
+                if ($title  && $title['name']) {
+                    $data['title_name'] = $title['name'];
+                }
+
+                if (!$data['buy_avatar']) {
+                    $data['buy_avatar'] = $member['avatar'];
+                } else {
+                    $data['buy_avatar'] = $con['avatar'];
+                }
+            }
+        } else {
+            return '核销码不存在或已核销';
+        }
+        return Dever::render('off_code', $data);
+    }
+    public function getInfoActive($active_id){
+        $data = Dever::db('active/info')->find($active_id);
+        $config = Dever::db('active/info')->config['config_act_status'];
+        if ($data) {
+            $data['status'] = Dever::status($data['status'],$config);
+            $data['act_time'] = date('Y.m.d H:i:s',$data['act_start']).'~'.date('Y.m.d H:i:s',$data['act_end']);
+            return $data['name'] .'    '.$data['status'].'<br/>'.$data['act_time'];
+        }
+
+    }
 }

+ 34 - 0
learn/active/src/Home.php

@@ -240,4 +240,38 @@ Class Home extends Core
             return $this->getCode();
         }
     }
+
+    public function confirm()
+	{
+		$code_id = Dever::input('code_id');
+		if (!$code_id) {
+			Dever::alert('核销码的id不能为空');
+		}
+		$data = Dever::db('active/code')->find($code_id);
+		if ($data) {
+			$active = Dever::db('active/info')->find($data['active_id']);
+			// if (time() < $active['act_start']){
+			// 	Dever::alert('活动未开始');
+			// }
+			if ($active['status'] == 5 || time() >= $active['act_end']) {
+				Dever::alert('活动已结束');
+			}
+			if ($data['status'] == 2) {
+				Dever::alert('当前核销码已核销');
+			}
+			$where['where_id'] = $code_id;
+			$where['status'] = 2;
+			$where['time'] = time();
+			$where['top_admin'] = $this->uid;
+			$ids = Dever::db('active/code')->update($where);
+			if ($ids) {
+				$data['msg'] = '核销成功';
+				return $data;#'核销成功';
+			} else {
+				Dever::alert('核销失败');
+			}
+		} else {
+			Dever::alert('核销码的信息不存在');
+		}
+	}
 }