Browse Source

Merge branch 'master' of ssh://git.dever.cc:10022/dever-product/churen

rabin 3 years ago
parent
commit
e7515fd982

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

@@ -250,7 +250,7 @@ return array
             (
                 'api' => 'passport/address-one',
                 'col' => 'contact',
-                'result' => 'uid',
+                'result' => 'address_id',
             ),
             'list'      => $search_option_shop_type == 1 ? 'Dever::load("shop/lib/manage.user", {id})' : 'Dever::load("passport/address-one#contact", {address_id})',
             'list_order' => 5,

+ 32 - 2
learn/active/database/code.php

@@ -5,6 +5,11 @@ $status = array
     2 => '已核销',
     3 => '已作废',
 );
+$type = array
+(
+    1 => '分享领取',
+    2 => '手动添加',
+);
 $act_status = array
 (
     1 => '未开始',
@@ -45,6 +50,7 @@ return array
             'desc'      => '活动名称',
             'match'     => 'is_string',
             'update'    => 'hidden',
+            'value'     => Dever::input('search_option_active_id'),
              'search'    => array
             (
                 'api' => 'active/info-getSearch',
@@ -114,7 +120,7 @@ return array
             'default'   => '',
             'desc'      => '核销码',
             'match'     => 'is_string',
-            'update'    => 'text',
+            // 'update'    => 'text',
             'search'    => 'fulltext',
             'list'      => true,
         ),
@@ -144,6 +150,18 @@ return array
             'list'      => true,
         ),
 
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '核销码来自哪的状态',
+            'default'   => '1',
+            'desc'      => '核销码来自哪的状态',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            // 'search'    => 'select',
+            // 'list'      => true,
+        ),
+
         'pic'       => array
         (
             'type'      => 'text-255',
@@ -151,7 +169,7 @@ return array
             'default'   => '',
             'desc'      => '二维码',
             'match'     => 'option',
-            'update'    => 'image',
+            // 'update'    => 'image',
             'key'       => '1',
             // 'place'     => '759*562',
         ),
@@ -190,6 +208,18 @@ return array
             // 'list_order'  => 8,
         ),
 
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '填写手机号-多个换行隔开,如手机号重复将不会录入到库中',
+            'default'   => '',
+            'desc'      => '填写手机号',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+            'value'     => '',
+            // 'show'      => 'type=2',
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 187 - 0
learn/active/database/create_code.php

@@ -0,0 +1,187 @@
+<?php
+$status = array
+(
+    1 => '待核销',
+    2 => '已核销',
+    3 => '已作废',
+);
+$act_status = array
+(
+    1 => '未开始',
+    2 => '报名中',
+    3 => '报名结束',
+    4 => '活动开始',
+    5 => '活动结束',
+);
+return array
+(
+    # 表名
+    'name' => 'creat_code',
+    # 显示给用户看的名称
+    'lang' => '生成核销码',
+    'menu' => false,
+    # 后台菜单排序
+    'order' => 2,
+    'start' => array
+    (
+        'insert' => 'active/lib/order.insertCode',
+    ),
+    'end' => array
+    (
+        'update' => 'active/lib/order.createCode',
+        'insert' => 'active/lib/order.createCode',
+    ),
+    // 'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+
+        'active_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '活动名称',
+            'default'   => '-1',
+            'desc'      => '活动名称',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_active_id'),
+             'search'    => array
+            (
+                'api' => 'active/info-getSearch',
+                'col' => 'col',
+                'result' => 'id',
+                'search' => 'active_id',
+            ),
+            'list'      => "Dever::load('active/lib/manage.active#active_name',{active_id})",
+        ),
+
+        'join_uid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '参加人名称/手机号',
+            'default'   => '-1',
+            'desc'      => '用户名称',
+            'match'     => 'is_string',
+            // 'option'    => $user,
+            // 'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'active/user-getSearch',
+                'col' => 'col',
+                'result' => 'id',
+                'search' => 'mid',
+            ),
+            'list_name' => '参加人信息',
+            'list'      => "Dever::load('active/lib/manage.user',{join_uid})",
+        ),
+
+        'write_code'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '核销码',
+            'default'   => '',
+            'desc'      => '核销码',
+            'match'     => 'is_string',
+            // 'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'pic'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '二维码',
+            'default'   => '',
+            'desc'      => '二维码',
+            'match'     => 'option',
+            // 'update'    => 'image',
+            'key'       => '1',
+            // 'place'     => '759*562',
+        ),
+
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '填写手机号-多个换行隔开,如手机号重复将不会录入到库中',
+            'default'   => '',
+            'desc'      => '填写手机号',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+            'value'     => '',
+            // 'show'      => 'type=2',
+        ),
+
+        '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
+    (
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'join_uid' => 'yes',
+                'active_id' =>'yes',
+                'status' => array('yes','in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            // 'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'join_uid' => array('yes','>='),
+                // 'active_id' =>'yes',
+                // 'status' => array('yes','in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

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

@@ -60,6 +60,9 @@ if ($search_auth == 1) {
     if (Dever::load('manage/auth')->checkFunc('active.info', 'editworld', '自定义字段设置')) {
         $list_button['list1'] = array('自定义字段设置', '"info_field&search_option_active_id={id}&oper_table=info"');
     }
+    if (Dever::load('manage/auth')->checkFunc('active.info', 'editcode', '生成核销码')) {
+        $list_button['fast_add'] = array('生成核销码', '"create_code&search_option_active_id={id}"');
+    }
 } else {
     if (Dever::load('manage/auth')->checkFunc('active.info_1', 'editOff', '核销活动')) {
         // $button['核销活动'] = array('fast',1,'info_code');

+ 66 - 0
learn/active/lib/Order.php

@@ -29,4 +29,70 @@ Class Order
         $w['where_id'] = $data['id'];
         Dever::db('active/order')->update($w);
     }
+    #生成核销码
+    public function insertCode($id,$name,$data)
+    {
+        $active_id = Dever::param('active_id',$data);
+        $content = Dever::param('content',$data);
+        $contents = Dever::split($content);
+        $active = Dever::db('active/info')->find($active_id);
+        if ($contents) {
+            foreach ($contents as $k => $v) {
+                $user = Dever::db('active/user')->find(array('mobile'=>$v));
+                if ($user) {
+                    $member = Dever::load('active/lib/user')->agent($user);
+                    $code = Dever::db('active/code')->getOne(array('active_id'=>$active_id,'join_uid'=>$user['id'],'status'=>'1,2'));
+                    if ($code) {
+                        Dever::alert('您已领取过了');
+                    }                 }
+            }
+        }
+    }
+    public function createCode($id,$name,$data) 
+    {
+        $active_id = Dever::param('active_id',$data);
+        $content = Dever::param('content',$data);
+        $contents = Dever::split($content);
+        $active = Dever::db('active/info')->find($active_id);
+        if ($contents) {
+            foreach ($contents as $k => $v) {
+                $user = Dever::db('active/user')->find(array('mobile'=>$v));
+                if ($user) {
+                    $member = Dever::load('active/lib/user')->agent($user);
+                    if ($member && $active['status'] == 2) {
+                        $this->user($active_id,$user['id']);
+                    } 
+                } else {
+                    $member = Dever::db('agent/member')->find(array('mobile'=>$v));
+                    if ($member) {
+                        $insert['name'] = $member['name'];
+                        $insert['mobile'] = $v;
+                        $insert['idcard'] = $member['idcard'];
+                        $insert['pass'] = $member['password'];
+                        $insert['old_pwd'] = $member['old_pwd'];
+                        $insert['old_salt'] = $member['old_salt'];
+                        $uid = Dever::db('active/user')->insert($insert);
+                        $this->user($active_id,$uid);
+                    } else {
+                        $insert['name'] = substr($v, 0, 3).'****'.substr($v, 7);
+                        $insert['mobile'] = $v;
+                        $uid = Dever::db('active/user')->insert($insert);
+                        $this->user($active_id,$uid);
+                    }
+                }
+            }
+            return 'ok';
+        }
+    }
+    private function user($active_id,$uid)
+    {
+        $w['active_id'] = $active_id;
+        $w['join_uid'] = $uid;
+        $w['write_code'] = Dever::load('active/home')->getCode();
+        $w['type'] = 2;
+        if ($uid && $uid >=1) {
+            Dever::db('active/code')->insert($w);
+        }
+        // Dever::db('active/creat_code')->insert($w);
+    }
 }

+ 9 - 6
learn/active/src/User.php

@@ -110,12 +110,15 @@ Class User extends Core
     		} else {
     			$data['info'][$k]['status_name'] = '已核销';
     		}
-    		if ($v['join_uid'] == $v['buy_uid']) {
-    			$data['info'][$k]['type_name'] = '来自自行购买订单';
-    		} else {
-    			$data['info'][$k]['type_name'] = '来自好友分享领取订单';
-    		}
-    		
+            if ($v['type'] == 1) {
+                if ($v['join_uid'] == $v['buy_uid']) {
+                    $data['info'][$k]['type_name'] = '来自自行购买订单';
+                } else {
+                    $data['info'][$k]['type_name'] = '来自好友分享领取订单';
+                }
+            } elseif ($v['type'] == 2) {
+                $data['info'][$k]['type_name'] = '来自手动发放';
+            }
     	}
     	return $data;
     }