Your Name 2 rokov pred
rodič
commit
a245f0f828

+ 27 - 0
learn/active/assets/manage/html/info_code.html

@@ -0,0 +1,27 @@
+
+<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">
+    <table class="layui-table">
+      <thead>
+        <tr>
+          <th>昵称</th>
+          <th>加入时间</th>
+          <th>签名</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+        <tr>
+          <td>许闲心</td>
+          <td>2016-11-28</td>
+          <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
+        </tr>
+      </tbody>
+    </table>
+</div>
+</form>

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

@@ -0,0 +1,232 @@
+<?php
+$status = array
+(
+    1 => '待核销',
+    2 => '已核销',
+);
+$act_status = array
+(
+    1 => '未开始',
+    2 => '报名中',
+    3 => '报名结束',
+    4 => '活动开始',
+    5 => '活动结束',
+);
+return array
+(
+    # 表名
+    'name' => 'code',
+    # 显示给用户看的名称
+    'lang' => '活动核销码',
+    # 后台菜单排序
+    'order' => 2,
+    // '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',
+            // 'search'    => 'text',
+            'list'      => "Dever::load('active/lib/manage.active#active_name',{active_id})",
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单名称',
+            'default'   => '-1',
+            'desc'      => '订单名称',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+            // 'search'    => 'text',
+            // 'list'      => true,
+        ),
+
+        '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})",
+        ),
+
+        'buy_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',{buy_uid})",
+        ),
+
+        'write_code'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '核销码',
+            'default'   => '',
+            'desc'      => '核销码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'act_status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '活动状态',
+            'default'   => '1',
+            'desc'      => '活动状态',
+            'match'     => 'is_numeric',
+            // 'update'    => 'radio',
+            'option'    => $act_status,
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '核销状态',
+            'default'   => '1',
+            'desc'      => '核销状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'pic'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '二维码',
+            'default'   => '',
+            'desc'      => '二维码',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            // 'place'     => '759*562',
+        ),
+
+        'offdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '核销时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            // 'search'    => 'date',
+            // 'desc'      => '',
+            // 'list'      => 'date("Y-m-d H:i:s", {zdate})',
+        ),
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '核销操作人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '核销操作人',
+            'list'      => 'Dever::load("active/lib/manage.active#admin_name",{id})',
+            // '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
+            // 'list_order'  => 8,
+        ),
+
+        'top_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '前台核销操作人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '核销操作人',
+            // 'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
+            // 'list_order'  => 8,
+        ),
+
+        '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' => '*',
+        ),
+    ),
+);

+ 330 - 25
learn/active/database/info.php

@@ -1,4 +1,84 @@
 <?php
+$status = array
+(
+    1 => '全部可购',
+    2 => '代理商可购',
+    3 => '非代理商可购',
+);
+
+$act_status = array
+(
+    1 => '未开始',
+    2 => '报名中',
+    3 => '报名结束',
+    4 => '活动开始',
+    5 => '活动结束',
+);
+
+$type = array
+(
+    1 => '商品预售',
+    2 => '活动门票',
+);
+
+$cost_type = array
+(
+    1 => '押金报名',
+    2 => '缴费报名',
+);
+
+$role = function()
+{
+    $array = array();
+    $data = Dever::load('setting/role-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+#权限:1=活动列表,2=核销管理
+$search_auth = Dever::input('search_option_dever_auth',1);
+$insert = false;
+$edit = false;
+$button = array();
+$list_button = array();
+if ($search_auth == 1) {
+    $insert = true;
+    $edit = true;
+    if (Dever::load('manage/auth')->checkFunc('active.info', 'editOffPeople', '核销人员设置')) {
+        // $list_button['核销人员'] = array('fast', 1,"info_off&search_option_off_id={off_id})");
+    }
+    if (Dever::load('manage/auth')->checkFunc('active.info', 'editworld', '字段设置')) {
+        $list_button['list1'] = array('字段设置', '"info_field&search_option_off_id={off_id}&oper_table=info"');
+    }
+} else {
+    if (Dever::load('manage/auth')->checkFunc('active.info', 'editOff', '核销活动')) {
+        $button['核销活动'] = array('fast',1,'info_code');
+    }
+}
+$off = function() use($search_auth)
+{
+    $array = array();
+    $data = Dever::load('active/info_off-getData', array('id' => 1));
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+$col = Dever::input('col');
+if (!$col) {
+    $tab = array('基础设置', '活动设置', '购买限制', '价格设置');
+} else {
+    $tab = '';
+}
+$attr = function()
+{
+    $auth = Dever::load('active/lib/manage.get',false);
+    // $auth = Dever::load('attr/api.get', false);
+    return $auth;
+};
 
 return array
 (
@@ -8,6 +88,7 @@ return array
     'lang' => '活动列表',
     # 后台菜单排序
     'order' => 2,
+    'config_act_status' => $act_status,
     # 数据结构
     'struct' => array
     (
@@ -35,18 +116,209 @@ return array
             'list'      => true,
         ),
 
+        'address'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '活动地址',
+            'default'   => '',
+            'desc'      => '活动地址',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            // 'search'    => 'fulltext',
+            // 'list'      => true,
+        ),
+
+        'banner'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '顶部banner',
+            'default'   => '',
+            'desc'      => '顶部banner',
+            'match'     => 'is_string',
+            'update'    => 'images',
+            'key'       => '1',
+            // 'place'     => '759*562',
+        ),
+
+        'sign_start'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '报名开始时间',
+            'match'     => 'option',
+            'default'   => '0',
+            'desc'      => '',
+            'match'     => 'option',
+            'update'    => 'date',
+            'search'    => 'date_start',
+            'callback'  => 'maketime',
+            'tab'       => 1,
+            // 'list'        => '{buy_date} > 0 ? date("Y-m-d H:i", {buy_date}) : "无"',
+        ),
+
+        'sign_end'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '报名结束时间',
+            'match'     => 'option',
+            'default'   => '0',
+            'desc'      => '',
+            'match'     => 'option',
+            'update'    => 'date',
+            'search'    => 'date_end',
+            'callback'  => 'maketime',
+            'tab'       => 1,
+            // 'list'        => '{buy_date} > 0 ? date("Y-m-d H:i", {buy_date}) : "无"',
+        ),
+
+        'act_start'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '活动开始时间',
+            'match'     => 'option',
+            'default'   => '0',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'update'    => 'date',
+            'search'    => 'date_start',
+            'callback'  => 'maketime',
+            'list'        => $search_auth == 2 ? 'date("Y-m-d H:i", {act_start})' : false,
+            'tab'       => 1,
+        ),
+
+        'act_end'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '活动结束时间',
+            'match'     => 'option',
+            'default'   => '0',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'update'    => 'date',
+            'search'    => 'date_end',
+            'callback'  => 'maketime',
+             'list'        => $search_auth == 2 ? 'date("Y-m-d H:i", {act_end})' : false,
+             'tab'       => 1,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '报名限制',
+            'default'   => '1',
+            'desc'      => '报名限制',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $status,
+            // 'search'    => 'select',
+            'list_name' => $search_auth == 2 ? '待核销数量' : false,
+            'list'      => $search_auth == 2 ? "Dever::load('active/lib/manage.dOff',{id})" : false,
+            'tab'       => 1,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '活动类型',
+            'default'   => '2',
+            'desc'      => '活动类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            // 'search'    => 'select',
+            'list'      => $search_auth == 1 ? true : false,
+            'tab'       => 1,
+        ),
+
+        'act_status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '活动状态',
+            'default'   => '1',
+            'desc'      => '活动状态',
+            'match'     => 'is_numeric',
+            // 'update'    => 'radio',
+            'option'    => $act_status,
+            'search'    => 'select',
+            'list'      => $search_auth == 1 ? true : false,
+            'tab'       => 1,
+        ),
+
         'num'      => array
         (
             'type'      => 'int-11',
             'name'      => '限购数量-单位:张',
-            'default'   => '',
+            'default'   => '0',
             'desc'      => '限购数量',
-            'match'     => 'is_string',
-            // 'update'    => 'text',
-            'search'    => 'fulltext',
+            'match'     => 'option',
+            'update'    => 'text',
+            // 'search'    => 'fulltext',
             // 'list'      => true,
+            'tab'       => 2,
+        ),
+
+        'attr'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '头衔购买数量设置',
+            'default'   => '',
+            'desc'      => '属性设置',
+            'match'     => 'option',
+            'update'    => 'checkbox',
+            'option'    => $attr,
+            'update_input' => '',
+            'update_input_default' => '',
+            'update_parent' => 'checkbox',
+            // 'list'      => 'Dever::load("attr/api.string", "{attr}", "{attr_input}")',
+            'tab'       => 2,
+        ),
+
+        'attr_input'        => array
+        (
+            'type'      => 'text-255',
+            'name'      => '属性值设置',
+            'default'   => '',
+            'desc'      => '属性值设置',
+            'match'     => 'option',
+            'updte'     => 'textarea',
+            'tab'       => 2,
         ),
 
+        // 'title'       => array
+        // (
+        //     'type'      => 'text-1000',
+        //     'name'      => '头衔购买数量',
+        //     'default'   => '',
+        //     'desc'      => '头衔购买数量',
+        //     'match'     => 'option',
+        //     'update'    => array
+        //     (
+                
+        //         array
+        //         (
+        //             'col'       => 'title',
+        //             'name'      => '头衔名称',
+        //             'default'   => '',
+        //             'desc'      => '头衔名称',
+        //             'match'     => 'is_string',
+        //             'update'    => 'select',
+        //             'option'    => $role,
+        //             'tab'       => 2,
+        //         ),
+        //         array
+        //         (
+        //             'col'       => 'num',
+        //             'name'      => '限购数量-单位:张',
+        //             'default'   => '0',
+        //             'desc'      => '限购数量',
+        //             'match'     => 'is_string',
+        //             'update'    => 'text',
+        //             'search'    => 'fulltext',
+        //             'tab'       => 2,
+        //         ),
+        //     ),
+        //     'tab'       => 2,
+        // ),
+
         'price'      => array
         (
             'type'      => 'decimal-11,2',
@@ -55,19 +327,23 @@ return array
             'desc'      => '票价-单位:元',
             'match'     => 'option',
             'update'    => 'text',
-            'list'      => true,
+            'list'      => $search_auth == 1 ? true : false,
+            'list_order' => '3',
+            'tab'       => 3,
         ),
 
-        'banner'       => array
+        'cost_type'        => array
         (
-            'type'      => 'text-255',
-            'name'      => '顶部banner',
-            'default'   => '',
-            'desc'      => '顶部banner',
-            'match'     => 'is_string',
-            'update'    => 'images',
-            'key'       => '1',
-            // 'place'     => '759*562',
+            'type'      => 'tinyint-1',
+            'name'      => '费用类型',
+            'default'   => '2',
+            'desc'      => '费用类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $cost_type,
+            // 'search'    => 'select',
+            // 'list'      => true,
+            'tab'       => 3,
         ),
 
         'pic'       => array
@@ -80,6 +356,7 @@ return array
             'update'    => 'image',
             'key'       => '1',
             // 'place'     => '759*562',
+            'tab'       => 3,
         ),
 
         'mobile'      => array
@@ -91,7 +368,19 @@ return array
             'match'     => 'option',
             'update'    => 'text',
             //'search'    => 'fulltext',
-            'list'      => true,
+            // 'list'      => true,
+            'tab'       => 3,
+        ),
+
+        'share_name'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '分享内容',
+            'default'   => '',
+            'desc'      => '分享内容',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'tab'       => 3,
         ),
 
         'desc'      => array
@@ -104,6 +393,20 @@ return array
             'update'    => 'editor',
             //'search'    => 'fulltext',
             //'list'      => true,
+            'tab'       => 3,
+        ),
+
+        'off_id'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '核销人员',
+            'default'   => '1',
+            'desc'      => '核销人员',
+            'match'     => 'option',
+            'search'    => 'selects',
+            'update'    => 'checkbox',
+            'option'    => $off,
+            // 'list'      => $search_auth == 2 ? true : false,
         ),
 
         'reorder'       => array
@@ -115,9 +418,9 @@ return array
             'match'     => 'option',
             'update'  => 'text',
             'search'    => 'order',
-            'list'      => true,
-            'order'     => 'desc',
-            'edit'      => true,
+            // 'list'      => true,
+            // 'order'     => 'desc',
+            // 'edit'      => true,
         ),
 
         'state'     => array
@@ -137,7 +440,7 @@ return array
             'desc'      => '',
             # 只有insert时才生效
             'insert'    => true,
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'list'      => $search_auth == 1 ? 'date("Y-m-d H:i:s", {cdate})' : false,
         ),
     ),
 
@@ -156,10 +459,12 @@ return array
 
     'manage' => array
     (
-    	//'insert' => false,
+    	'insert' => $insert,
         'delete' => false,
-        // 'edit' => false,
-        
+        'edit' => $edit,
+        'list_button' => $list_button,
+        'button' => $button,
+        'tab'  => $tab,
     ),
 
     'request' => array
@@ -169,12 +474,12 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                // 'id' => array('yes','>'),
+                'id' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
-            'order' => array('reorder' => 'desc', 'id' => 'asc'),
-            'col' => '*',
+            'order' => array('reorder' => 'desc', 'act_status' => 'asc'),
+            'col' => 'id,name,banner,act_status,sign_end,act_start,act_end',
         ),
     ),
 );

+ 95 - 0
learn/active/database/info_code.php

@@ -0,0 +1,95 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'info_code',
+    # 显示给用户看的名称
+    'lang' => '活动核销码',
+    # 后台菜单排序
+    'order' => 2,
+    'menu' => false,
+    'start' => array
+    (
+    	'insert' => 'active/lib/manage.insertInfoCode',
+    ),
+    'end' => array 
+    (
+    	'insert' => 'active/lib/manage.updateInfoCode',
+    	'update' => 'active/lib/manage.updateInfoCode',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '核销码',
+            'default'   => '',
+            'desc'      => '核销码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            // 'search'    => 'fulltext',
+            // 'list'      => true,
+            'bind'        => array('onblur', 'loading', array('url' => Dever::url("active/lib/manage.search"))),
+        ),
+
+        '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,
+        'page_list' => 'info_code',        
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'join_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 133 - 0
learn/active/database/info_field.php

@@ -0,0 +1,133 @@
+<?php
+$type = array
+(
+    1 => '文本框',
+    2 => '下拉框',
+);
+$id = Dever::input('search_option_active_id');
+return array
+(
+    # 表名
+    'name' => 'info_field',
+    # 显示给用户看的名称
+    'lang' => '字段设置',
+    # 后台菜单排序
+    'order' => 2,
+    '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',
+            'value'     => $id,
+            'update'    => 'hidden',
+            // 'search'    => 'text',
+            'list'      => "Dever::load('active/lib/manage.active',{active_id})",
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '名称',
+            'default'   => '',
+            'desc'      => '名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'search'    => 'select',
+            'list'      => true,
+            'control'	=> 'type',
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序-数值越大越靠前',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'  => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+    	//'insert' => false,
+        'delete' => false,
+        // 'edit' => false,
+        'list_button' => array
+		(
+			'list1' => array('属性值设置', '"info_field_value&project=active&search_option_field_id={id}&oper_table=info_field&oper_project=active&top_table=info&search_option_active_id={active_id}"' , '{type} > 1'),
+			
+		),
+    ),
+
+    'request' => array
+    (
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'actives_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc','type'=>'asc'),
+            'col' => 'id,name,type',
+        ),
+    ),
+);

+ 134 - 0
learn/active/database/info_field_value.php

@@ -0,0 +1,134 @@
+<?php
+$id = Dever::input('search_option_field_id');
+$active_id = Dever::input('search_option_active_id');
+return array
+(
+    # 表名
+    'name' => 'info_field_value',
+    # 显示给用户看的名称
+    'lang' => '属性值设置',
+    # 是否显示在后台菜单
+    'order' => 9,
+    'menu'  => false,
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+
+        'field_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '字段属性id',
+            'default'   => '1',
+            'desc'      => '字段属性id',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => $id,
+        ),
+
+        'active_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '活动id',
+            'default'   => '1',
+            'desc'      => '活动id',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => $active_id,
+            'list'      => "Dever::load('active/lib/manage.active',{active_id})",
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '属性值名称-如绿色',
+            'default'   => '',
+            'desc'      => '属性值名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'value'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '属性具体值-如上述名称为绿色,这里可以是绿色的色值,选填项,可以为空',
+            'default'   => '',
+            'desc'      => '属性具体值',
+            'match'     => 'option',
+            // 'update'    => 'text',
+            // 'search'    => 'fulltext',
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+        
+        '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'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+
+    ),
+
+    'request' => array
+    (
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'active_id' => 'yes',
+                'field_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => 'id,active_id,field_id,name',
+        ),
+    )
+);

+ 146 - 0
learn/active/database/info_off.php

@@ -0,0 +1,146 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'info_off',
+    # 显示给用户看的名称
+    'lang' => '活动核销人员',
+    # 后台菜单排序
+    'order' => 2,
+    // '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',
+        //     'value'     => Dever::input('search_option_active_id'),
+        //     'update'    => 'hidden',
+        //     // 'search'    => 'text',
+        //     // 'list'      => true,
+        // ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '核销人员姓名',
+            'default'   => '',
+            'desc'      => '核销人员姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'bigint-11',
+            'name'      => '核销人员电话',
+            'default'   => '',
+            'desc'      => '请输入电话',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'pass'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '登录密码',
+            'default'   => '',
+            'desc'      => '登录密码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            // 'list'      => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序-数值越大越靠前',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'  => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+    	//'insert' => false,
+        'delete' => false,
+        // 'edit' => false,
+        
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                //'id' => array('yes', '!='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*|id',
+        ),
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                // 'id' => array('yes','>'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'asc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 116 - 0
learn/active/database/info_refund.php

@@ -0,0 +1,116 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'info_refund',
+    # 显示给用户看的名称
+    'lang' => '活动退款记录',
+    # 后台菜单排序
+    'order' => 2,
+    'menu' => false,
+    'start' => array
+    (
+    	'insert' => 'active/lib/manage.insertInfoRefund',
+    ),
+    'end' => array 
+    (
+    	'insert' => 'active/lib/manage.updateInfoRefund',
+    	// '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})",
+        ),
+
+        'num'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款数量-单位:张',
+            'default'   => '0',
+            'desc'      => '限购数量',
+            'match'     => 'option',
+            'update'    => 'text',
+            // 'search'    => 'fulltext',
+            // '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' => '*',
+        ),
+    ),
+);

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

@@ -2,9 +2,11 @@
 $excel = false;
 $excel[] = array('数据导出','数据导出','active/lib/excel.out_active_order');
 $list_button = array();
-if (Dever::load('manage/auth')->checkFunc('active.order', 'editRefund', '全额退款')) {
-    $list_button['oper'] = array('全额退款', '"active/lib/manage.refund?id={id}"', '{status} == 2');
+if (Dever::load('manage/auth')->checkFunc('active.order', 'editRefund', '退款')) {
+    $list_button['fast'] = array('退款', '"info_refund&project=active&search_option_order_id={id}"');
+    // $list_button['oper'] = array('退款', '"active/lib/manage.refund?id={id}"', '{status} == 2');
 }
+$list_button['list'] = array('查看详情','"info_code&project=active&id={id}&page_type=1&[refer]"');
 $pay_type = array
 (
     1 => '在线支付',
@@ -85,6 +87,19 @@ return array
             'list'      => 'Dever::load("agent/lib/member.getOne", {mid}, "agent/member", true)',
         ),
 
+        'uid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名称',
+            'default'   => '-1',
+            'desc'      => '用户名称',
+            'match'     => 'is_string',
+            // 'option'    => $user,
+            // 'update'    => 'text',
+            // 'search'    => 'text',
+            // 'list'      => true,
+        ),
+
         'active_id'      => array
         (
             'type'      => 'int-11',
@@ -143,6 +158,16 @@ return array
             'list'      => true,
         ),
 
+        'path'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '自定义字段',
+            'default'   => '',
+            'desc'      => '自定义字段',
+            'match'     => 'option',
+            // 'update'    => 'textarea',
+        ),
+
         'remark'      => array
 	    (
 	        'type'      => 'varchar-300',
@@ -229,6 +254,7 @@ return array
             'option' => array
             (
                 'mid' => 'yes',
+                'uid'  => 'yes',
                 'active_id' => 'yes',
                 'status' =>2,
                 'state' => 1,
@@ -242,6 +268,7 @@ return array
             'option' => array
             (
                 'mid' => 'yes',
+                'uid' => 'yes',
                 'status' => array('yes','!='),
                 'state' => 1,
             ),

+ 207 - 0
learn/active/database/user.php

@@ -0,0 +1,207 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'user',
+    # 显示给用户看的名称
+    'lang' => '活动用户列表',
+    # 后台菜单排序
+    'order' => 2,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '代理商姓名/手机号',
+            'default'   => '-1',
+            'desc'      => '代理商',
+            'match'     => 'is_string',
+            // 'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'agent/member-getSearch',
+                'col' => 'col',
+                'result' => 'id',
+                'search' => 'mid',
+            ),
+            'list_name' => '代理商信息',
+            'list'      => 'Dever::load("agent/lib/member.getOne", {mid}, "agent/member", true)',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '名称',
+            'default'   => '',
+            'desc'      => '名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'bigint-11',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '请输入手机号',
+            'match'     => Dever::rule('mobile'),
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'idcard'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '身份证号码',
+            'default'   => '',
+            'desc'      => '身份证号码',
+            'match'     => Dever::rule('idcard'),
+            'update'    => 'text',
+        ),
+
+        'username'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '昵称',
+            'default'   => '',
+            'desc'      => '昵称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'birthday'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '生日',
+            'default'   => '',
+            'match'     => 'option',
+            'desc'      => '生日',
+            'update'    => 'time',
+            'callback'  => 'maketime',
+        ),
+
+        'pass'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '登录密码',
+            'default'   => '',
+            'desc'      => '登录密码',
+            'match'     => 'is_string',
+            'update'    => 'password',
+            // 'search'    => 'fulltext',
+            'callback'  => 'sha1',
+        ),
+
+        'old_pwd'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => 'pwd',
+            'default'   => '',
+            'desc'      => 'pwd',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'old_salt'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => 'salt',
+            'default'   => '',
+            'desc'      => 'salt',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'avatar'        => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '头像',
+            'default'   => '',
+            'desc'      => '请选择头像',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            //'place'       => '150',
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序-数值越大越靠前',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'  => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+    	'insert' => false,
+        'delete' => false,
+        'edit' => false,
+  //       'list_button' => array
+		// (
+		// 	'list1' => array('属性值设置', '"info_field_value&project=active&search_option_field_id={id}&oper_table=info_field&oper_project=active&top_table=info&search_option_actives_id={actives_id}"' , '{type} > 1'),
+			
+		// ),
+    ),
+
+    'request' => array
+    (
+        'getSearch' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'col' => array('yes-mobile,name', 'like'),
+            ),
+            'type' => 'all',
+            'col' => '*|id',
+        ),
+    ),
+);

+ 115 - 0
learn/active/lib/Active.php

@@ -0,0 +1,115 @@
+<?php
+
+namespace Active\Lib;
+
+use Dever;
+use Active\Lib\Core;
+
+class Active extends Core
+{
+    public function action($uid, $active_id, $num, $path, $remark = false)
+    {
+    	$user = Dever::db('active/user')->find($uid);
+		// print_R(json_decode('[{"id":"1","value":"文本"},{"id":"2","value":"文本"},{"id":"3","value":"1"}]'));die;
+		$data = Dever::db('active/info')->find($active_id);
+		// print_R($data);die;
+		$user = $this->user;
+		$insert['active_id'] = $active_id;
+		$insert['mid'] = $user['mid'];
+		$insert['num'] = $num;
+		$insert['price'] = $num * $data['price'];
+		if ($remark) {
+			$insert['remark'] = $remark;
+		}
+		if ($path) {
+			$insert['path'] = $path;
+		}
+		$insert['uid'] = $user['id'];
+		$title = array();
+		if ($data['attr']) {
+			if ($data['attr_input']) {
+				$input['num'] = explode(',',$data['attr_input']);
+			}
+			$data['attr'] = explode(',',$data['attr']);
+			foreach ($data['attr'] as $k => $v) {
+				foreach ($input['num'] as $k1 => $v1) {
+					if($k == $k1){
+						$title[$k]['id'] = $v;
+						$title[$k]['num'] = $v1;
+					}
+				}
+			}
+		}
+		$data = Dever::db('active/order')->getNum(array('uid'=>$uid,'active_id'=>$active_id));
+		$member = Dever::db('agent/member')->find(array('mobile'=>$user['mobile']));
+		if ($member) {
+			foreach ($title as $k => $v) {
+				if($v['id'] == $member['role']) {
+					if ($data && $data['total']  && $v['num'] > 0 && $data['total'] > $v['num']) {
+						Dever::alert('您已超过限购数量');
+					}
+				}
+			}
+		}
+		if ($data && $data['total'] && $data['tatal'] > $data['num']) {
+			Dever::alert('您已超过限购数量');
+		}
+		$insert['order_num'] = $this->getOrderId();
+		$ids = Dever::db('active/order')->insert($insert);
+
+		$url = Dever::url();
+		$refer = 'https://www.churenyiliao.com/';
+		if (strstr($url, 'uat.')) {
+			$refer = 'http://guanli.uat.churenyiliao.com/';
+		}
+		$refer .= 'data/payback/active.html?order_id=' . $ids;
+		if ($ids) {
+			$info = Dever::db('active/order')->find($ids);
+			$active = Dever::db('active/info')->find($info['active_id']);
+			$param = array
+	        (
+	            'project_id' => 6,
+	            'channel_id' => 1,
+	            'system_source' => 1,
+	            'account_id' => 8,
+	            'uid' => $this->uid,
+	            'name' => $active['name'],
+	            //'openid' => $data['openid'],
+	            'cash' => $info['price'],
+	            'product_id' => $ids,
+	            'order_id' => $info['order_num'],
+	            'h5' => 1,
+	            'refer' => $refer,
+	        );
+
+	        $result = Dever::load('pay/api.pay', $param);
+	        if ($result['order']) {
+	        	Dever::db('active/order')->update(array('where_id'=>$ids,'url'=>$result['order']));
+	        }
+	        $result['order_num'] = $info['order_num'];
+	        $result['order_id'] = $info['id'];
+	        $jump = Dever::input('jump');
+	        if ($jump == 1) {
+	        	Dever::location($result['order']);
+	        }
+
+	        return $result;
+		} else {
+			Dever::alert('提交失败');
+		}
+    }
+
+    #生成订单号
+    public function getOrderId()
+    {
+        $where['order_num'] = Dever::order('D');
+        $where['clear'] = true;
+        $state = Dever::db('active/order')->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+	
+}

+ 41 - 0
learn/active/lib/Core.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace Active\Lib;
+
+use Dever;
+
+class Core
+{
+    protected $uid = -1;
+    protected $use = array();
+    protected $check = true;
+    public $data = array();
+
+    public function __construct()
+    {
+        $this->uid = Dever::load('passport/user')->check(false);
+        if ($this->uid <= 0) {
+            //$this->uid = 1;
+        }
+        if ($this->check) {
+            $this->checkLogin();
+        }
+        
+        if ($this->uid) {
+            $this->user = Dever::db('active/user')->find($this->uid);
+            // $this->user['uid'] = $this->user['id'];
+        }
+        if ($this->check) {
+            if ($this->user) {
+                $this->user['uid'] = $this->user['id'];
+            } 
+        }
+    }
+
+    public function checkLogin()
+    {
+        if (!$this->uid || $this->uid <= 0) {
+            Dever::alert('请先登录', -2);
+        }
+    }
+}

+ 112 - 4
learn/active/lib/Cron.php

@@ -4,16 +4,124 @@ namespace Active\Lib;
 Use Dever;
 Class Cron{
 	#活动订单定时关闭
-    public function job_api(){
+    public function job_api()
+    {
     	$data = Dever::db('active/order')->state(array('status'=>1));
     	$time = time();
-    	if($data){
-    		foreach($data as $k => $v){
-    			if ($v['cdate'] && $time-$v['cdate']>300){
+    	if ($data) {
+    		foreach ($data as $k => $v) {
+    			if ($v['cdate'] && $time-$v['cdate']>300) {
     				Dever::db('active/order')->update(array('where_id'=>$v['id'],'set_status'=>3));
     			}
     		}
     	}
     	return 'ok';
     }
+    #活动状态
+    public function status_api()
+    {
+        $data = Dever::db('active/info')->state();
+        $time = time();
+        if ($data) {
+            $where = array();
+            foreach ($data as $k =>$v) {
+                if ($v['sign_start']) {
+                    $ids = $this->start($v['cdate'],$v['act_start'],$v['act_end'],$v['sign_start'],$v['sign_end']);
+                } else {
+                   $ids = $this->start($v['cdate'],$v['act_start'],$v['act_end']);
+                }
+                $where['where_id'] = $v['id'];
+                $where['act_status'] = $ids['act_status'];
+                Dever::db('active/info')->update($where);
+            }
+        }
+        return 'ok';
+    }
+    public function code_api()
+    {
+        $data = Dever::db('active/code')->state();
+        if ($data) {
+            foreach ($data as $k => $v) {
+                if ($v['active_id']) {
+                    $active = Dever::db('active/info')->find($v['active_id']);
+                    if ($active['sign_start']) {
+                        $ids = $this->start($active['cdate'],$active['act_start'],$active['act_end'],$active['sign_start'],$active['sign_end']);
+                    } else {
+                       $ids =  $this->start($active['cdate'],$active['act_start'],$active['act_end']);
+                    }
+                    $where['where_id'] = $v['id'];
+                    $where['act_status'] = $ids['act_status'];
+                    Dever::db('active/code')->update($where);
+                }
+            }
+            return 'ok';
+        }
+    }
+
+    public function start($cdate, $act_start, $act_end, $sign_start = false, $sign_end = false)
+    {
+        $time = time();
+        if ($sign_start) {
+            if ($time < $sign_start){
+                $where['act_status'] = 1;
+            } elseif ($sign_end) {
+                if ($time >= $sign_start && $time < $sign_end) {
+                    $where['act_status'] = 2;
+                } elseif ($time > $sign_end && $time < $act_start) {
+                    $where['act_status'] = 3;
+                } elseif ($time > $act_start && $time < $act_end) {
+                    $where['act_status'] = 4;
+                } elseif ($time > $act_end) {
+                    $where['act_status'] = 5;
+                }
+            } 
+        } else {
+            if($time < $cdate) {
+                $where['act_status'] = 1;
+            } elseif ($time > $cdate && $time < $act_start) {
+                $where['act_status'] = 2;
+            } elseif ($time > $act_start && $time < $act_end) {
+                $where['act_status'] = 4;
+            } elseif ($time > $act_end) {
+                $where['act_status'] = 5;
+            }
+        }
+        return $where;
+    }
+    #更新user表
+    public function user_api()
+    {
+        $data = Dever::db('active/order')->state();
+        foreach ($data as $k => $v) {
+            if ($v['mid'] && $v['mid'] > 0) {
+                $member = Dever::db('agent/member')->find($v['mid']);
+                if ($member && $member['mobile']) {
+                    $user = Dever::db('active/user')->find(array('mobile'=>$member['mobile']));
+                    if (!$user) {
+                        $insert['mid'] = $v['mid'];
+                        $insert['name'] = $member['name'];
+                        $insert['mobile'] = $member['mobile'];
+                        $insert['idcard'] = $member['idcard'];
+                        $insert['pass'] = $member['password'];
+                        $insert['old_pwd'] = $member['old_pwd'];
+                        $insert['old_salt'] = $member['old_salt'];
+                        Dever::db('active/user')->insert($insert);
+                    }
+                } 
+            }
+        }
+    }
+    #更新订单表
+    public function setUSer_api()
+    {
+        $data = Dever::db('active/order')->state();
+        foreach ($data as $k => $v) {
+            $user = Dever::db('active/user')->find(array('mid'=>$v['mid']));
+            if ($user) {
+                $where['where_id'] = $v['id'];
+                $where['uid'] = $user['id'];
+                Dever::db('active/order')->update($where);
+            }
+        }
+    }
 }

+ 380 - 8
learn/active/lib/Manage.php

@@ -3,10 +3,34 @@
 namespace Active\Lib;
 
 use Dever;
-Class Manage {
+Class Manage 
+{
 	#全额退款
-	public function refund_api($id){
+	public function refund_api($id)
+    {
 		$data = Dever::db('active/order')->find($id);
+        if ($data['mid'] && $data['mid'] > 0) {
+            $user = Dever::db('active/user')->find(array('mid'=>$data['mid']));
+            if ($user && $user['id']) {
+                $uid = $user['id'];
+            }
+        } else {
+            $uid = $data['uid'];
+        }
+        $active = Dever::db('active/info')->find($data['active_id']);
+        if (time() > $active['act_start']) {
+            Dever::alert('活动已开始,不能退款');
+        }
+        $code = Dever::db('active/code')->state(array('order_id'=>$data['id'],'buy_uid'=>$uid));
+        $icode = Dever::db('active/code')->state(array('order_id'=>$data['id'],'buy_uid'=>$uid,'status'=>1));
+        $count = count($code);
+        $num = $data['num'] - $count;
+        if ($count == 0 ) {
+            $price = $data['price'];
+        } elseif ( $count > 0 && $num > 0) {
+            $inum = count($icode);
+            $price = ($num + $inum) * $active['price'];
+        }
 		$param = array
         (
             'project_id' => 6,
@@ -14,13 +38,14 @@ Class Manage {
             'system_source' => 1,
             'account_id' => 8,
             'order_id' => $data['order_num'],
-            'refund_cash' => $data['price'],
+            'refund_cash' => $price,
             //'refund_order_id' => '',
         );
-        if($data['status'] != 2){
+        if ($data['status'] != 2) {
         	Dever::alert('此状态下不可退款');
         }
 
+
         if ($data['price'] > 0) {
             $result = Dever::load('pay/api.refund', $param);
 
@@ -28,16 +53,86 @@ Class Manage {
                 # 退款失败,抛出错误
                 //throw new \Exception('退款失败');
                 Dever::alert('退款失败,请联系管理员');
-            }else{ 
+            } else { 
                 $admin = Dever::load('manage/auth.data');
                 $time = time();
-            	Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>6,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
+                if ($price == $data['price']) {
+                    Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>6,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
+                } else {
+                    Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>5,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
+                }
+            	
             }
         }
   		return 'reload';
 	}
+    public function insertInfoRefund ($id,$name,$data)
+    {
+        $num = Dever::param('num',$data);
+        $order_id = Dever::param('order_id',$data);
+        $data = Dever::db('active/order')->find($order_id);
+        if($num > $data['num']) {
+            Dever::alert('退款数量大于购买数量');
+        }
+        $info = Dever::db('active/info_refund')->state(array('order_id'=>$order_id));
+        $count = $data['num'] - count($info);
+        if ($num > $count) {
+            Dever::alert('退款数量大于购买数量');
+        }
+    }
+
+    public function updateInfoRefund ($id,$name,$data)
+    {
+        $num = Dever::param('num',$data);
+        $order_id = Dever::param('order_id',$data);
+        $data = Dever::db('active/order')->find($order_id);
+        $info = Dever::db('active/info_refund')->state(array('order_id'=>$order_id));
+        $active = Dever::db('active/info')->find($data['active_id']);
+        // if (time() >= $active['act_start']) {
+        //     Dever::alert('活动已开始,不能退款');
+        // }
+        // if ($num > $data['num']) {
+        //     Dever::alert('退款数量大于购买数量');
+        // }
+
+        $price = $num * $active['price'];
+        $refund_num = $data['order_num'] . '_' . count($info);
+        $param = array
+        (
+            'project_id' => 6,
+            'channel_id' => 1,
+            'system_source' => 1,
+            'account_id' => 8,
+            'order_id' => $data['order_num'],
+            'refund_cash' => $price,
+            'refund_order_id' => $refund_num,
+        );
+        if ($data['status'] != 2) {
+            Dever::alert('此状态下不可退款');
+        }
+        if ($price > 0) {
+            $result = Dever::load('pay/api.refund', $param);
+
+            if (!$result) {
+                # 退款失败,抛出错误
+                //throw new \Exception('退款失败');
+                Dever::alert('退款失败,请联系管理员');
+            } else { 
+
+                $admin = Dever::load('manage/auth.data');
+                $time = time();
+                if ($price == $data['price']) {
+                    Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>6,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
+                } else {
+                    Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>5,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
+                }
+            }
+        }
+        return 'reload';
+    }
 
-    public function show($id){
+    public function show($id)
+    {
         $data = Dever::db('active/order')->find($id);
         $refund_admin = '-';
         $rdate = '-';
@@ -47,7 +142,284 @@ Class Manage {
             $rdate = date('Y-m-d H:i',$data['rdate']);
         }
         $html = $refund_admin.'<br/>'.$rdate;
-        // print_R($html);die;
         return $html;
     }
+
+    public function active($id)
+    {
+        $data = Dever::db('active/info')->find($id);
+        $html = array();
+        $html['active_name'] = $data['name'];
+        $info = Dever::db('active/code')->find($id);
+        if ($info && isset($info['audit_admin']) && $info['audit_admin']  && $info['audit_admin'] > 0) {
+            $aduit = Dever::load('manage/admin-find',$info['audit_admin']);
+            $html['admin_name'] = $aduit['username'];
+        } elseif ($info && $info['top_admin']) {
+            $off = Dever::db('active/off')->find($info['top_admin']);
+            $html['admin_name'] = $off['name'];
+        }
+        return $html;
+    }
+    public function user($id)
+    {
+        $data = Dever::db('active/user')->find($id);
+        $html = $data['name'].'<br/>'.$data['mobile'];
+        return $html;
+    }
+    public function dOff($id)
+    {
+        $data = Dever::db('active/code')->state(array('active_id' => $id,'status'=>1));
+        $html = count($data);
+        return $html;
+    }
+    public function insertInfoCode($id, $name, $data)
+    {
+        $code = Dever::param('code',$data);
+        if ($code) {
+            $info = Dever::db('active/info_code')->find(array('code'=>$code));
+            if ($info['code']) {
+                Dever::alert('核销码已核销');
+            }
+        }
+    }
+    public function updateInfoCode($id, $name, $data)
+    {
+        $code = Dever::param('code',$data);
+        $data = Dever::db('active/code')->find(array('write_code'=>$code));
+        if ($data) {
+            $where['where_id'] = $data['id'];
+            $where['status'] = 2;
+            $where['offdate'] = time();
+            $admin = Dever::load('manage/admin-find');
+            $where['audit_admin'] = $admin['id'];
+            Dever::db('active/code')->update($where);
+        }
+
+    }
+    public function get()
+    {
+        $data[0]['name'] = '头衔';
+        $data[0]['child'] = Dever::db('setting/title')->select();
+        $data['state'] = 1;
+        return $data;
+    }
+    public function search_api()
+    {
+        $value = Dever::input('value');
+        if (!$value) {
+            return '核销码不存在';
+        }
+        if ($value) {
+            $data = Dever::db('active/code')->one(array('write_code' => $value,'state' =>1));
+            $table = array();
+            if ($data) {
+                $user = Dever::db('active/user')->find(array('id'=>$data['join_uid']));
+                $parent = Dever::db('active/user')->find(array('id'=>$data['buy_uid']));
+                $table = array();
+                $table['head'] = array('姓名', '手机号','邀请人', '邀请人手机号');
+                $table['body'] = array();
+                $table['body'] = array($user['name'], $user['mobile'],$parent['name'], $parent['mobile']);
+                
+                $result[] = array
+                (
+                    'type' => 'table',
+                    'content' => $table,
+                );
+
+                $html = Dever::show('', $result, false, false);
+                return $html;
+            }else{
+                return '核销码不存在';
+            }
+        } else {
+            return '';
+        }
+    }
+
+    public function checkMcode()
+    {
+        $mobile = Dever::input('mobile');
+        $code = Dever::input('mcode');
+        if (!$code) {
+            Dever::alert('请输入验证码');
+        }
+        $code = Dever::load('passport/reg')->mcode($mobile, $code, 2);
+        if (!$code) {
+            Dever::alert('验证码输入错误');
+        }
+        return 'ok';
+    }
+
+    public function list()
+    {
+        $id = Dever::input('id');
+        $info = Dever::db('active/order')->find($id);
+        $active = Dever::db('active/info')->find($info['active_id']);
+        $config = Dever::db('active/order')->config['config_status'];
+        $status = Dever::status($config,$info['status']);
+        if ( !$info['uid']) {
+            $user = Dever::db('active/user')->find($info['mid']);
+            $info['uid'] = $user['id'];
+        }
+        $code = Dever::db('active/code')->state(array('order_id' => $id, 'buy_uid'=>$info['uid']));
+        $use_code = count($code);
+        $no_code = $info['num'] - $use_code;
+        if ($info['mid'] && $info['mid'] > 0) {
+            $user = Dever::db('active/user')->find($info['mid']);
+            $member = Dever::db('agent/member')->find($info['mid']);
+            if ($member) { 
+                $role = Dever::db('setting/role')->find($member['role']);
+                if (isset($role) && $role && isset($role['name']) && $role['name']) {
+                    $role_name = '<br/>'.$role['name'];
+                } else {
+                    $role_name = '';
+                }
+                $title = Dever::db('setting/title')->find($member['title_id']);
+                if (isset($title) && $title && isset($title['name']) && $title['name']) {
+                    $title_name = '('.$title['name'].')';
+                } else {
+                    $title_name = '';
+                }
+                $level = Dever::db('setting/level')->find($member['level_id']);
+                if (isset($level) && $level && isset($level['name']) && $level['name']) {
+                    $level_name = '('.$level['name'].')';
+                } else {
+                    $level_name = '';
+                }
+                $user_name = $member['name'].$role_name.$title_name.$level_name;
+                $user_mobile = $member['mobile'];
+                $user_idcard = $member['idcard'];
+            }
+        } elseif ($info['uid'] && $info['uid'] > 0) {
+            $user = Dever::db('active/user')->find($info['uid']);
+            if ($user) {
+                $user_name = $user['name'];
+                $user_mobile = $user['mobile'];
+                $user_idcdard = $user['idcard'];
+            }
+        }
+        $result['订单信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('订单单号', $info['order_num']),
+                    array('活动名称', $active['name']),
+                    array('订单状态', $status),
+                ),
+                array
+                (
+                    array('购买数量', $info['num']),
+                    array('支付金额', $info['price']),
+                ),
+                array
+                (
+                    array('已使用', $use_code),
+                    array('未使用', $no_code),
+                ),
+            ),
+        );
+        $result['用户信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('用户姓名', $user_name),
+                    array('用户电话', $user_mobile),
+                    array('用户身份证号', $user_idcard),
+                ),
+            ),
+        );
+        if ($use_code > 0) {
+           $result +=  $this->table($id,$user['id']);
+            
+        }
+        $head = array
+        (
+            'name' => '基本资料',
+            'btn' => '',
+        );
+        $html = Dever::show($head, $result);
+        return $html;
+    }
+
+    private function table ($id,$uid) 
+    {
+        $data = Dever::db('active/code')->state(array('order_id' => $id, 'join_uid' => $uid));
+        if ($data) {
+            $head = array('参加人信息', '核销码', '核销状态', '领取时间', '核销时间','核销人');
+            $body = array();
+            foreach ($data as $k => $v) {
+                $user = Dever::db('active/user')->find($v['join_uid']);
+                $join_name = '';
+                if ($user) {
+                    $join_name = $user['name'].'<br/>'.$user['mobile'];
+                }
+                $admin_name = '';
+                if ($v['status'] == 1) {
+                    $status = '待核销';
+                } else {
+                    $status = '已核销';
+                   if ($v['audit_admin'] && $v['audit_admin'] >0) {
+                       $admin = Dever::load('manage/admin-find',$v['audit_admin']);
+                       if ($admin) {
+                            $admin_name = $admin['username'];
+                       } 
+                   } else {
+                        if ($v['top_admin'] && $v['top_admin'] > 0) {
+                            $admin = Dever::db('active/info_off')->find($v['top_admin']);
+                            if ($admin) {
+                                $admin_name = $admin['name'];
+                            }
+                        }
+                   }
+                }
+                $cdate = '';
+                if ($v['cdate']) {
+                    $cdate = date('Y-m-d H:i',$v['cdate']);
+                }
+                $offdate = '';
+                if ($v['offdate']) {
+                    $offdate = date('Y-m-d H:i',$v['offdate']);
+                }
+                $d = array
+                (
+                    $join_name,
+                    $v['write_code'],
+                    $status,
+                    $cdate,
+                    $offdate,
+                    $admin_name,
+                );
+                $body[] = $d;
+            }
+            $result['核销码使用列表'] = array
+            (
+                'type' => 'table',
+                'content' => array
+                (
+                    'head' => $head,
+                    'body' => $body,
+                )
+            );
+           return $result;
+        }
+    }
+    // #将已经注册活动的用户放到用户表中
+    // public function user_cron()
+    // {
+    //     $data = Dever::db('active/order')->state();
+    //     foreach ($data as $k => $v) {
+    //         $user = Dever::db('active/user')->find(array('mid'=>$v['mid']));
+    //         if (!$user) {
+    //             $member = Dever::db('agent/member')->find($v['mid']);
+    //             $where['mobile'] = $member['mobile'];
+    //             $where['idcard'] = $member['idcard'];
+    //         }
+    //     }
+    // }
 }

+ 41 - 0
learn/active/lib/OffCroe.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace Active\Lib;
+
+use Dever;
+
+class OffCroe
+{
+    protected $uid = -1;
+    protected $use = array();
+    protected $check = true;
+    public $data = array();
+
+    public function __construct()
+    {
+        $this->uid = Dever::load('passport/user')->check(false);
+        if ($this->uid <= 0) {
+            $this->uid = 1;
+        }
+        if ($this->check) {
+            $this->checkLogin();
+        }
+        
+        if ($this->uid) {
+            $this->user = Dever::db('active/info_off')->find($this->uid);
+            // $this->user['uid'] = $this->user['id'];
+        }
+        if ($this->check) {
+            if ($this->user) {
+                $this->user['uid'] = $this->user['id'];
+            } 
+        }
+    }
+
+    public function checkLogin()
+    {
+        if (!$this->uid || $this->uid <= 0) {
+            Dever::alert('请先登录', -2);
+        }
+    }
+}

+ 20 - 63
learn/active/src/Api.php

@@ -4,7 +4,9 @@ namespace Active\Src;
 use Dever;
 use Agent\Lib\Core;
 
-Class Api extends Core {
+Class Api extends Core 
+{
+	
 	#活动详情
 	public function index(){
 		$id = Dever::input('id');
@@ -16,71 +18,21 @@ Class Api extends Core {
 		return $data;
 	}
 	#确认信息
-	public function confirm(){
+	public function confirm()
+	{
+		$uid = $this->uid;
 		$id = Dever::input('id');
-		if(!$id){
+		if (!$id) {
 			Dever::alert('活动id不能为空');
 		}
 		$num = Dever::input('num');
-		if(!$num){
+		if (!$num) {
 			Dever::alert('购买数量不能为空');
 		}
 		$remark = Dever::input('remark');
-		$data = Dever::db('active/info')->find($id);
-		$insert['active_id'] = $id;
-		$insert['mid'] = $this->uid;
-		$insert['num'] = $num;
-		$insert['price'] = $num * $data['price'];
-		if($remark){
-			$insert['remark'] = $remark;
-		}
-		$data = Dever::db('active/order')->getNum(array('mid'=>$this->uid,'active_id'=>$id));
-		// if($data && $data['total'] && $data['tatal'] > $data['num']){
-		// 	Dever::alert('您已超过限购数量');
-		// }
-		$insert['order_num'] = $this->getOrderId();
-		$ids = Dever::db('active/order')->insert($insert);
-
-		$url = Dever::url();
-		$refer = 'https://www.churenyiliao.com/';
-		if (strstr($url, 'uat.')) {
-			$refer = 'http://guanli.uat.churenyiliao.com/';
-		}
-		$refer .= 'data/payback/active.html?order_id=' . $ids;
-		if($ids){
-			$info = Dever::db('active/order')->find($ids);
-			$active = Dever::db('active/info')->find($info['active_id']);
-			$param = array
-	        (
-	            'project_id' => 6,
-	            'channel_id' => 1,
-	            'system_source' => 1,
-	            'account_id' => 8,
-	            'uid' => $this->uid,
-	            'name' => $active['name'],
-	            //'openid' => $data['openid'],
-	            'cash' => $info['price'],
-	            'product_id' => $ids,
-	            'order_id' => $info['order_num'],
-	            'h5' => 1,
-	            'refer' => $refer,
-	        );
-
-	        $result = Dever::load('pay/api.pay', $param);
-	        if($result['order']){
-	        	Dever::db('active/order')->update(array('where_id'=>$ids,'url'=>$result['order']));
-	        }
-	        $result['order_num'] = $info['order_num'];
-	        $result['order_id'] = $info['id'];
-	        $jump = Dever::input('jump');
-	        if ($jump == 1) {
-	        	Dever::location($result['order']);
-	        }
-
-	        return $result;
-		}else{
-			Dever::alert('提交失败');
-		}
+		$path = Dever::input('path');
+		$result = Dever::load('active/lib/active')->action($uid, $id, $num, $path, $remark);
+		return $result;
 	}
 
 	 # 支付成功回调 安全加密 设置token
@@ -141,19 +93,22 @@ Class Api extends Core {
         return $order;
     }
     
-	#门票列表
-	public function getList(){
+	#门票列表,我的订单列表
+	public function getList()
+	{
 		$data['list'] = Dever::db('active/order')->getAll(array('mid'=>$this->uid,'status'=>3));
 		foreach($data['list'] as $k => $v){
 			$active = Dever::db('active/info')->find($v['active_id']);
 			$data['list'][$k]['active_name'] = $active['name'];
-			$data['list'][$k]['cdate'] = date('Y-m-d H:i',$v['cdate']);
+			$data['list'][$k]['cdate'] = date('Y.m.d H:i',$v['cdate']);
 			$config = Dever::db('active/order')->config['config_status'];
 			$data['list'][$k]['status_name'] = Dever::status($config,$v['status']);
+			$data['list'][$k]['total_price'] = $v['num'] * $v['price'];
+			$data['list'][$k]['pay_time'] = '';
 		}
 		return $data;
 	}
-	#详情页
+	#订单详情页
 	public function getDesc(){
 		$id = Dever::input('id');
 		if (!$id) {
@@ -180,6 +135,7 @@ Class Api extends Core {
 		}
 		return $data;
 	}
+	
 
 	#生成订单号
     public function getOrderId()
@@ -193,4 +149,5 @@ Class Api extends Core {
             return $this->getOrderId();
         }
     }
+    
 }

+ 117 - 0
learn/active/src/Auth.php

@@ -0,0 +1,117 @@
+<?php
+namespace Active\Src;
+
+use Dever;
+Class Auth
+{
+	#验证码登录
+	public function login()
+	{
+		$mobile = Dever::input('mobile');
+		$pass = Dever::input('pass');
+		$user = Dever::db('active/user')->find(array('mobile'=>$mobile));
+		if (!$pass) {
+			$this->checkMcode($mobile);
+		} 
+		if ($user) {
+			if($user['pass'] != sha1($pass) && $user['old_pwd'] != md5($pass. $user['old_salt'])) {
+				Dever::alert('密码不正确');
+			}
+			$data = Dever::load('passport/reg')->getSign($user['id']);
+            return $data;
+		} else {
+			$member = Dever::db('agent/member')->find(array('mobile'=>$mobile));
+			if ($member) {
+				if($member['pass'] != sha1($pass) && $member['old_pwd'] != md5($pass. $member['old_salt'])) {
+					Dever::alert('密码不正确');
+				}
+				$insert['mid'] = $member['id'];
+				$insert['name'] = $member['name'];
+				$insert['mobile'] = $member['moible'];
+				$insert['idcard'] = $member['idcard'];
+				$insert['pass'] = $member['password'];
+				$insert['old_pwd'] = $member['old_pwd'];
+				$insert['old_salt'] = $member['old_salt'];
+				$ids = Dever::db('active/user')->insert($insert);
+			} else {
+				$where['mobile'] = $mobile;
+				$where['name'] = substr($mobile, 0, 3).'****'.substr($mobile, 7);
+				$ids = Dever::db('active/user') -> insert($where);
+			}
+			if ($ids) {
+				$data = Dever::load('passport/reg')->getSign($ids);
+        		return $data;
+			}
+		}
+	}
+
+	#注册
+	public function reg()
+	{
+		$where['name'] = Dever::input('name');
+		$where['mobile'] = Dever::input('mobile');
+		$where['idcard'] = Dever::input('idcard');
+		$data = Dever::db('active/user')->find(array('mobile'=>$mobile));
+		if (!$data) {
+			$this->checkMcode($where['mobile']);
+			$ids = Dever::db('active/user')->insert($where);
+			if ($ids) {
+				$data = Dever::load('passport/reg')->getSign($ids);
+				return $data;
+			}
+			
+		} else {
+			Dever::alert('该手机号已注册');
+		}
+	}
+	#验证码
+	public function getLoginMcode()
+    {
+        $mobile = Dever::input('mobile');
+
+        $code = Dever::load('passport/reg')->mcode($mobile);
+
+        $msg = '验证码已发送至您的手机,请注意查收,十分钟之内有效';
+        $debug = Dever::config('base', 'project')->mobileCode['debug'];
+        if ($debug) {
+            $msg .= '::' . $code;
+        }
+        return $msg;
+    }
+
+    public function checkMcode()
+    {
+        $mobile = Dever::input('mobile');
+        $code = Dever::input('mcode');
+        if (!$code) {
+            Dever::alert('请输入验证码');
+        }
+        $code = Dever::load('passport/reg')->mcode($mobile, $code, 2);
+        if (!$code) {
+            Dever::alert('验证码输入错误');
+        }
+        return 'ok';
+    }
+
+    #核销登录
+    public function offLogin()
+    {
+    	$mobile = Dever::input('mobile');
+    	if (!$mobile) {
+    		Dever::alert('手机号不存在');
+    	}
+    	$pass = Dever::input('pass');
+    	$data = Dever::db('active/off')->find(array('mobile'=>$mobile));
+    	if ($mobile != $data['mobile']) {
+    		Dever::alert('手机号还未注册');
+    	}
+    	if (!$pass || $pass != $data['pass']) {
+    		Dever::alert('密码不能为空或密码不存在');
+    	}
+    	if ($data) {
+			$data = Dever::load('passport/reg')->getSign($data['id']);
+            return $data;
+		}
+
+    }
+}

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

@@ -0,0 +1,85 @@
+<?php
+namespace Active\Src;
+use Dever;
+use Active\Lib\Core;
+
+Class Home extends Core
+{
+	protected $check = false;
+	#活动首页
+	public function get()
+	{
+		$data['info'] = Dever::db('active/info')->getAll(array('state'=>1));
+		$config = Dever::db('active/info')->config['config_act_status'];
+		foreach($data['info'] as $k=>$v){
+			$data['info'][$k]['act_status_name'] = Dever::status($config,$v['act_status']);
+			if ($v['act_status'] == 2) {
+				if ($v['sign_end']) {
+					$data['info'][$k]['day'] = '剩余'.floor(($v['sign_end'] - time())/86400).'天';
+				} else {
+					$data['info'][$k]['day'] = '剩余'.floor(($v['act_start'] - time())/86400).'天';
+				}
+			}else {
+				$data['info'][$k]['day'] = '';
+			}
+		}
+		return $data;
+	}
+
+	# 活动报名获取信息
+	public function getSign()
+	{
+		$uid = $this->uid;
+		$id = Dever::input('id');
+		$this->data['info'] = Dever::db('active/info')->find($id);
+		$this->data['info']['banner'] = explode(',', $this->data['info']['banner']);
+		$this->data['info']['field'] = Dever::db('active/info_field')->getList(array('active_id'=>$id,'state'=>1));
+		foreach($this->data['info']['field'] as $k => $v){
+			if($v['type'] == 2) {
+				$this->data['info']['field'][$k]['value_name']= Dever::db('active/info_field_value')->getList(array('active_id'=>$id,'field_id'=>$v['id']));
+				
+			}else{
+				$this->data['info']['field'][$k]['value_name'] = '';
+			}
+		}
+		if ($uid > 0) {
+			$this->data['user'] = Dever::db('active/user')->find($uid);
+		}
+		return $this->data;
+	}
+
+	# 活动报名页
+	public function upSign()
+	{
+		$data['name'] = Dever::input('name');
+		$data['mobile'] = Dever::input('mobile');
+		$data['idcard'] = Dever::input('idcard');
+
+		$uid = $this->uid;
+		if ($this->uid <= 0) {
+			$user = Dever::db('active/user')->find(array('mobile'=>$data['mobile']));
+			if ($user) {
+				$uid = $user['id'];
+			} else {
+				# 注册
+				$uid = Dever::db('active/user')->insert($data);
+			}
+		}
+		$result = array();
+		$result = Dever::load('passport/reg')->getSign($uid);
+
+		$id = Dever::input('id');
+		if (!$id) {
+			Dever::alert('活动id不能为空');
+		}
+		$num = Dever::input('num');
+		if (!$num) {
+			Dever::alert('购买数量不能为空');
+		}
+		$remark = Dever::input('remark');
+		$path = Dever::input('path');
+
+		$result += Dever::load('active/lib/active')->action($uid, $id, $num, $path, $remark);
+		return $result;
+	}
+}

+ 91 - 0
learn/active/src/Off.php

@@ -0,0 +1,91 @@
+<?php
+namespace Active\Src;
+
+use Dever;
+use Active\Lib\OffCroe;
+
+Class Off extends OffCroe
+{
+	#核销首页
+	public function getHome()
+	{
+		$data['user'] = $this->user;
+		$data['info'] = Dever::db('active/info')->getAll($data['user']['active_id']);
+		foreach ($data['info'] as $k => $v) {
+			$data['info'][$k]['act_time'] = date('Y-m-d H:i',$v['act_start']).'~'.date('Y-m-d H:i',$v['act_end']);
+			unset($data['info'][$k]['sign_end'],$data['info'][$k]['act_start'],$data['info'][$k]['act_end']);
+		}
+		return $data;
+	}
+	#核销列表信息
+	public function getList(){
+		$code = Dever::input('code');
+		$where['active_id'] = Dever::input('active_id');
+		$count = strlen($code);
+		$res = array();
+		$where['status'] = 1;
+		if ($count > 6) {
+			$where['mobile'] = $code;
+			$data = Dever::db('active/code')->find($where);
+		} else {
+			$where['write_code'] = $code;
+			$data = Dever::db('active/code')->find($where);
+		}
+		if ($data) {
+			$user = Dever::db('active/user')->find($data['join_uid']);
+			$res['info']['code_id'] = $data['id'];
+			$res['info']['name'] = $user['name'];
+			$res['info']['mobile'] = $user['mobile'];
+			$parent_user = Dever::db('active/user')->find($data['buy_uid']);
+			$res['info']['parent_name'] = $parent_user['name'];
+			$res['info']['parent_mobile'] = $parent_user['mobile'];
+			$member = Dever::db('agent/member')->find(array('mobile'=>$user['mobile']));
+			if (!$member) {
+				$res['member'] = array();
+			} else {
+				$res['member']['role_name'] = '';
+				$res['member']['title_name'] = '';
+				$res['member']['mobile'] = $member['mobile'];
+				$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']){
+    					$res['member']['role_name'] = $role['name'] .'('.$level['name'].')';
+    				} else {
+    					$res['member']['role_name'] = $role['name'];
+    				}
+    			}
+    			if ($title  && $title['name']) {
+    				$res['member']['title_name'] = $title['name'];
+    			}
+			}
+		} else {
+			Dever::alert('手机号不正确或核销码已核销');
+		}
+		return $res;
+	}
+	#确认核销
+	public function getConfirm()
+	{
+		$code_id = Dever::input('code_id');
+		if (!$code_id) {
+			Dever::alert('核销码的id不能为空');
+		}
+		$data = Dever::db('active/code')->find($code_id);
+		if ($data) {
+			$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) {
+				return $data;
+			} else {
+				Dever::alert('核销失败');
+			}
+		} else {
+			Dever::alert('核销码的信息不存在');
+		}
+	}
+}

+ 252 - 0
learn/active/src/User.php

@@ -0,0 +1,252 @@
+<?php
+namespace Active\Src;
+use Dever;
+use Active\Lib\Core;
+
+Class User extends Croe
+{
+	 #领取
+    public function recive()
+    {
+    	$user = $this->user;
+    	$active_id = Dever::input('active_id');
+    	$order_id = Dever::input('id');
+    	$info = Dever::db('active/info')->find($active_id);    	
+    	$member = Dever::db('agent/member')->find(array('mobile'=>$user['mobile']));
+    	if ($info['status']  == 2) {
+    		if (!$member) {
+    			Dever::alert('仅限代理商购买');
+    		}
+    	} elseif ($info['status'] == 3) {
+    		if ($member) {
+    			Dever::alert('代理商不可购买');
+    		}
+    	} 
+    	Dever::load('active/lib/manage')->checkMcode($mobile);
+    	$code = Dever::db('active/code')->state(array('order_id'=>$order_id));
+    	$data = Dever::db('active/order')->find($order_id);
+    	if ($data['num'] <= count($code)) {
+    		Dever::alert('已领完');
+    	} else {
+    		$where['active_id'] = $data['active_id'];
+    		$where['buy_uid'] = $data['uid'];
+    		$where['join_uid'] = $uid;
+    		$where['order_id'] = $order_id;
+    		$where['act_status'] = $info['act_status'];
+    		$code = Dever::db('active/code')->find($where);
+    		if ($code) {
+    			Dever::alert('您已领取过了,不可重复领取');
+    		}
+    		$where['write_code'] = substr(base_convert(md5(uniqid(md5(microtime(true)),true)), 16, 10), 0, 6);
+    		$code = Dever::db('active/code')->find(array('write_code'=>$where['write_code']));
+        	if ($code) {
+        		$where['write_code'] = substr(base_convert(md5(uniqid(md5(microtime(true)),true)), 16, 10), 0, 6);
+        	}
+        	$ids = Dever::db('active/code')->insert($where);
+        	if ($ids) {
+        		$data = Dever::db('active/code')->find($ids);
+        		return $data;
+        	}
+    	}
+    }
+    #查看核销码
+    public function getSeeCode()
+    {
+    	$where['join_uid'] = $this->uid;
+    	$where['order_id'] =  Dever::input('id');
+    	$where['active_id'] = Dever::input('active_id');
+    	$data = Dever::db('active/code')->find($where);
+    	if ($data) {
+    		$string = $data['write_code'];
+    		$pic = Dever::load('qrcode/api.qrcode', $string, $local = true, $logo = false, $uid = false);
+    		$where['where_id'] = $data['id'];
+    		$where['pic'] = Dever::url($pic['url']);
+    		$ids = Dever::db('active/code')->update($where);
+    		$data = Dever::db('active/code')->find($ids);
+    		return $data;
+    	}
+    }
+    #我的核销码
+    public function getMyCode()
+    {
+    	$uid = $this->uid;
+    	$data['info'] = Dever::db('active/code')->getAll(array('join_uid'=>$uid));
+    	foreach ($data['info'] as $k => $v) {
+    		$active = Dever::db('active/info')->find($v['active_id']);
+    		$data['info'][$k]['active_name'] = $active['name'];
+    		$data['info'][$k]['cdate'] = date('Y-m-d H:i',$v['cdate']);
+    		if ($v['status'] == 1) {
+    			$data['info'][$k]['status_name'] = '待核销';
+    		} else {
+    			$data['info'][$k]['status_name'] = '已核销';
+    		}
+    		if ($v['join_uid'] == $v['buy_uid']) {
+    			$data['info'][$k]['type_name'] = '来自自行购买订单';
+    		} else {
+    			$data['info'][$k]['type_name'] = '来自好友分享领取订单';
+    		}
+    		
+    	}
+    	return $data;
+    }
+    #我的订单列表
+	public function getList()
+	{
+		$data['list'] = Dever::db('active/order')->getAll(array('uid'=>$this->uid,'status'=>3));
+		foreach($data['list'] as $k => $v){
+			$active = Dever::db('active/info')->find($v['active_id']);
+			$data['list'][$k]['active_name'] = $active['name'];
+			$data['list'][$k]['cdate'] = date('Y.m.d H:i',$v['cdate']);
+			$config = Dever::db('active/order')->config['config_status'];
+			$data['list'][$k]['status_name'] = Dever::status($config,$v['status']);
+			$data['list'][$k]['total_price'] = $v['num'] * $v['price'];
+			$data['list'][$k]['pay_time'] = '';
+		}
+		return $data;
+	}
+    #订单详情页
+    public function getDesc()
+	{
+		$id = Dever::input('id');
+		if (!$id) {
+			Dever::alert('订单id不能为空');
+		}
+		$user = $this->user;
+		$data['user']['name'] = $user['name'];
+		$data['user']['mobile'] = $user['mobile']; 
+		$data['user']['idcard'] = $user['idcard'];
+		$data['info'] = Dever::db('active/order')->find($id);
+		if ($data['info']) {
+			$active = Dever::db('active/info')->find($data['info']['active_id']);
+			$data['info']['active_name'] = $active['name'];
+			$data['info']['cash'] = $active['price'];#单价
+			$data['info']['cdate'] = date('Y-m-d H:i',$data['info']['cdate']);
+			$config = Dever::db('active/order')->config['config_status'];
+			$data['info']['status_name'] = Dever::status($config,$data['info']['status']);
+			$data['info']['refund_cash'] = '';#全额退款金额
+			if ($data['info']['status'] == 6) {
+				$data['info']['refund_cash'] = $data['info']['price'];
+			}
+			$data['info']['share_name'] = '';
+			if ($active['share_name']) {
+				$data['info']['share_name'] = $active['share_name'];
+			}
+			$data['info']['mobile'] = $active['mobile'];
+			#使用核销码
+			$code = Dever::db('active/code')->state(array('order_id'=>$id));
+			$no_code = $data['info']['num']-count($code);
+			if ($data['info']['status'] == 4) {
+				$data['info']['use_code'] = '已使用'.count($code).'个';
+				$data['info']['no_code'] = '未使用'.$no_code.'个';
+				if ($code) {
+					foreach ($code as $k => $v) {
+						if ($v['status'] == 1) {
+							$status = '待核销';
+						} else {
+							$status = '已核销';
+						}
+						$user = Dever::db('active/user')->find($v['join_uid']);
+						$data['info']['code'][$k]['name'] = $user['name'];
+						$data['info']['code'][$k]['mobile'] = '手机尾号'.substr($user['mobile'],-4).','.$status;
+					}
+				}
+			} else {
+				$data['info']['use_code'] = '';
+				$data['info']['no_code'] = '';
+			}
+			
+		} else {
+			Dever::alert('订单不存在');
+		}
+		return $data;
+	}
+    #我的页面
+    public function getMy()
+    {
+    	$data['user'] = $this->user;
+    	if ($data['user']) {
+    		$data['user']['role_name'] = '';
+    		$data['user']['title_name'] = '';
+    		$member = Dever::db('agent/member')->find(array('mobile'=>$data['user']['mobile']));
+    		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['user']['role_name'] = $role['name'] .'('.$level['name'].')';
+    				} else {
+    					$data['user']['role_name'] = $role['name'];
+    				}
+    			}
+    			if ($title  && $title['name']) {
+    				$data['user']['title_name'] = $title['name'];
+    			}
+    		}
+    	} else {
+    		$data['user']['name'] = '匿名用户';
+    	}
+    	$config = Dever::db('setting/base-one');
+    	$data['config']['phone'] = $config['phone'];
+    	return $data;
+    }
+    #修改密码
+    public function setPass()
+    {
+    	$pass = Dever::input('pass');
+        if (!$pass) {
+            Dever::alert('请输入密码');
+        }
+
+        $where['where_id'] = $this->uid;
+        $where['pass'] = $pass;
+
+        Dever::db('active/user')->update($where);
+
+        return Dever::db('active/user')->find(array('id' => $this->uid, 'clear' => true));
+
+    }
+    #修改资料
+    public function setInfo()
+    {
+    	$where = array();
+        $avatar = Dever::input('avatar');
+        if ($avatar) {
+            $where['avatar'] = $avatar;
+        }
+        $username = Dever::input('username');
+        if ($username) {
+            $where['username'] = $username;
+        }
+        $birthday = Dever::input('birthday');
+        if ($birthday) {
+            $where['birthday'] = Dever::maketime($birthday);
+        }
+
+        if ($where) {
+            $where['where_id'] = $this->uid;
+            Dever::db('active/user')->update($where);
+            return Dever::db('active/user')->find(array('id' => $this->uid, 'clear' => true));
+        }
+    }
+
+    #取消订单
+	public function cancel()
+	{
+		$order_id = Dever::input('id');
+		$data = Dever::db('active/order')->find(array('uid'=>$this->uid,'id'=>$order_id));
+		if ($data) {
+			$where['where_id'] = $data['id'];
+			$where['state'] = 2;
+			$ids = Dever::db('active/order')->update($where);
+			if ($ids) {
+				$data = Dever::db('active/order')->find($ids);
+				return $data;
+			} else {
+				Dever::alert('取消失败');
+			}
+		} else {
+			Dever::alert('此订单不存在');
+		}
+	}
+}

+ 5 - 0
learn/active/template/manage/info_code.php

@@ -0,0 +1,5 @@
+<?php
+
+$view
+->fetch('#show', 'active/lib/manage.list')
+->display();

+ 1 - 0
main/database/help.php

@@ -9,6 +9,7 @@ $type = array
     5 => '网站',
     6 => '代理商',
     7 => '期权',
+    8 => '商学院',
 );
 
 $config = array

+ 27 - 0
service/agent/assets/manage/html/option_policy.html

@@ -0,0 +1,27 @@
+
+<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">
+    <table class="layui-table">
+      <thead>
+        <tr>
+          <th>昵称</th>
+          <th>加入时间</th>
+          <th>签名</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+        <tr>
+          <td>许闲心</td>
+          <td>2016-11-28</td>
+          <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
+        </tr>
+      </tbody>
+    </table>
+</div>
+</form>

+ 118 - 21
service/agent/database/option_account.php

@@ -25,7 +25,36 @@ $audit = array
     2 => '拒绝',
 );
 $col = Dever::input('col');
-
+$policy = function()
+{
+    $array = array();
+    $data = Dever::load('agent/option_policy-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+$exercise = function()
+{
+    $array = array();
+    $data = Dever::load('agent/option_exercise-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+$release = function()
+{
+    $array = array();
+    $data = Dever::load('agent/option_release-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
 return array
 (
     # 表名
@@ -86,6 +115,16 @@ return array
             // 'search'    => 'fulltext',
             // 'list'      => true,
         ),
+
+        'email'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '邮箱',
+            'default'   => '',
+            'desc'      => '请输入邮箱',
+            'match'     => 'option||' . Dever::rule('email'),
+            'update'    => 'text',
+        ),
      	
        'idcard'      => array
         (
@@ -121,6 +160,17 @@ return array
             // 'list'      => true,
         ),
 
+        'number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '门店编号',
+            'default'   => '',
+            'desc'      => '门店编号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            // 'list'      => true,
+        ),
+
         'title'      => array
         (
             'type'      => 'varchar-100',
@@ -159,22 +209,36 @@ return array
         'price'      => array
         (
             'type'      => 'decimal-11,2',
-            'name'      => '设备费用-单位:万元',
+            'name'      => '开店投入金额-单位:元',
             'default'   => '0',
-            'desc'      => '设备费用',
-            'match'     => 'option',
+            'desc'      => '开店投入金额',
+            'match'     => 'is_numeric',
             'update'    => 'text',
-            'list_name' => '资金记录明细(万元)',
+            'list_name' => '开店投入金额<br/>政策对应期权价值<br/>实际补贴期权价值',
             'list'      => 'Dever::load("agent/lib/option_account.show#price",{id})',
+            'list_order' => 9,
+        ),
+
+        'policy_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '零售店政策',
+            'default'   => '',
+            'desc'      => '零售店政策',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'    => 'radio',
+            'option'    => $policy,
+            // 'list'      => $search_auth == 2 ? true : false,
         ),
 
         'zh_price'      => array
         (
             'type'      => 'decimal-11,2',
-            'name'      => '装修费用-单位:万元',
+            'name'      => '政策对应期权价值-单位:元',
             'default'   => '0',
-            'desc'      => '装修费用',
-            'match'     => 'option',
+            'desc'      => '政策对应期权价值',
+            'match'     => 'is_numeric',
             'update'    => 'text',
             // 'list'      => true,
         ),
@@ -182,25 +246,51 @@ return array
         'zj_price'      => array
         (
             'type'      => 'decimal-11,2',
-            'name'      => '租金费用-单位:万元',
+            'name'      => '实际补贴期权价值-单位:元',
             'default'   => '0',
-            'desc'      => '租金费用',
+            'desc'      => '实际补贴期权价值',
             'match'     => 'option',
-            'update'    => 'text',
+            // 'update'    => 'text',
             // 'list'      => true,
         ),
 
-        'other_price'      => array
+        'exercise_id'      => array
         (
-            'type'      => 'decimal-11,2',
-            'name'      => '其他费用-单位:万元',
-            'default'   => '0',
-            'desc'      => '其他费用',
-            'match'     => 'option',
-            'update'    => 'text',
-            // 'list'      => true,
+            'type'      => 'varchar-32',
+            'name'      => '行权条件',
+            'default'   => '',
+            'desc'      => '行权条件',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'    => 'checkbox',
+            'option'    => $exercise,
+            // 'list'      => $search_auth == 2 ? true : false,
         ),
 
+        'release_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '释放比例',
+            'default'   => '',
+            'desc'      => '释放比例',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'    => 'radio',
+            'option'    => $release,
+            // 'list'      => $search_auth == 2 ? true : false,
+        ),
+
+        // 'other_price'      => array
+        // (
+        //     'type'      => 'decimal-11,2',
+        //     'name'      => '其他费用-单位:万元',
+        //     'default'   => '0',
+        //     'desc'      => '其他费用',
+        //     'match'     => 'option',
+        //     'update'    => 'text',
+        //     // 'list'      => true,
+        // ),
+
         'pic'       => array
         (
             'type'      => 'text-255',
@@ -294,6 +384,7 @@ return array
             'mul'       => true,
             'control'   => 'audit',
         ),
+
         'remark'      => array
         (
             'type'      => 'varchar-600',
@@ -367,13 +458,19 @@ return array
     	// 'insert' => $insert,
     	'delete' => false,
     	'edit'   => false,
-    	'page_list' => 'option_account',
+    	// 'page_list' => 'option_account',
         // 'button' => $button,
     	'list_button' => array
         (
-        	 'list' => array('查看详情', '"option_account&project=agent&id={id}&page_type=1&[refer]"'),
+        	 'list' => array('查看详情', '"option_policy&project=agent&id={id}&page_type=1&[refer]"'),
         	 // 'list' => array('查看详情', 'Dever::load("agent/lib/option_account.list",{id})'),
         ),
+        'button' => array
+        (
+             '零售政策' => array('location', 'l=project/database/list&project=agent&table=option_policy&&oper_table=option_account'),
+             '行权条件' => array('location', 'l=project/database/list&project=agent&table=option_exercise&&oper_table=option_account'),
+             '释放比例' => array('location', 'l=project/database/list&project=agent&table=option_release&oper_table=option_account'),
+        ),
     ),
 
     'request' => array

+ 94 - 0
service/agent/database/option_exercise.php

@@ -0,0 +1,94 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'option_exercise',
+    # 显示给用户看的名称
+    'lang' => '行权条件',
+    # 后台菜单排序
+    'order' => 2,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '条件名',
+            'default'   => '',
+            'desc'      => '条件名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序-数值越大越靠前',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'  => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+    	//'insert' => false,
+        // 'delete' => false,
+        // 'edit' => false,
+    ),
+
+    'request' => array
+    (
+        'getSearch' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'col' => array('yes-mobile,name', 'like'),
+            ),
+            'type' => 'all',
+            'col' => '*|id',
+        ),
+    ),
+);

+ 95 - 0
service/agent/database/option_policy.php

@@ -0,0 +1,95 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'option_policy',
+    # 显示给用户看的名称
+    'lang' => '零售政策',
+    # 后台菜单排序
+    'order' => 2,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '条件名',
+            'default'   => '',
+            'desc'      => '条件名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序-数值越大越靠前',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'  => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+    	//'insert' => false,
+        // 'delete' => false,
+        // 'edit' => false,
+        'page_list' => 'option_policy',
+    ),
+
+    'request' => array
+    (
+        'getSearch' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'col' => array('yes-mobile,name', 'like'),
+            ),
+            'type' => 'all',
+            'col' => '*|id',
+        ),
+    ),
+);

+ 94 - 0
service/agent/database/option_release.php

@@ -0,0 +1,94 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'option_release',
+    # 显示给用户看的名称
+    'lang' => '释放比例',
+    # 后台菜单排序
+    'order' => 2,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '条件名',
+            'default'   => '',
+            'desc'      => '条件名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序-数值越大越靠前',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'  => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+    	//'insert' => false,
+        // 'delete' => false,
+        // 'edit' => false,
+    ),
+
+    'request' => array
+    (
+        'getSearch' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'col' => array('yes-mobile,name', 'like'),
+            ),
+            'type' => 'all',
+            'col' => '*|id',
+        ),
+    ),
+);

+ 69 - 10
service/agent/lib/Option_account.php

@@ -10,8 +10,8 @@ Class Option_account{
 		$info = Dever::db('agent/option_account')->find($id);
 		$data =array();
 		$data['list'] = $info['name'].'<br/>'.$info['mobile'].'<br/>'.$info['idcard'];
-		$count = $info['price']+$info['zh_price']+$info['zj_price']+$info['other_price'];
-		$data['price'] = '设备费:'.$info['price'].'<br/>装修费:'.$info['zh_price'].'<br/>租金费:'.$info['zj_price'].'<br/>其他:'.$info['other_price'].'<br/>总计:'.$count;
+		// $count = $info['price']+$info['zh_price']+$info['zj_price'];
+		$data['price'] = $info['price'].'<br/>'.$info['zh_price'].'<br/>'.$info['zj_price'];
 		$config = Dever::db('agent/option_account')->config['config_status'];
 		$status = Dever::status($config,$info['status']);
 		if($info['jf_date']){
@@ -45,8 +45,8 @@ Class Option_account{
 		if($info['type'] == 1){
 			$type_name = '零售店';
 		}
-		$count = $info['price']+$info['zh_price']+$info['zj_price']+$info['other_price'];
-		$info_price = '设备费:'.$info['price'].'万元;装修费:'.$info['zh_price'].'万元;租金费:'.$info['zj_price'].'万元;其他:'.$info['other_price'].'万元;总计:'.$count.'万元';
+		$count = $info['price']+$info['zh_price']+$info['zj_price'];
+		$info_price = '设备费:'.$info['price'].'万元;装修费:'.$info['zh_price'].'万元;租金费:'.$info['zj_price'].'万元';
 		$area = Dever::load("area/api.string", $info['area']);
 		$area = str_replace(',','',$area);
 		$image = explode(',',$info['pic']);
@@ -68,6 +68,28 @@ Class Option_account{
 		}
         $config = Dever::db('agent/option_account')->config['config_status'];
 		$status = Dever::status($config,$info['status']);
+		$policy = Dever::db('agent/option_policy')->find($info['policy_id']);
+		$policy_name = '';
+		if ($policy && $policy['name']) {
+			$policy_name = $policy['name'];
+		}
+		$exe = explode(',', $info['exercise_id']);
+		foreach ($exe as $k => $v) {
+			$exer[] = Dever::db('agent/option_exercise')->find($v);
+		}
+		// print_R($exercise);die;
+		$exercise_name = '';
+		if ($exer) {
+			$ex = array_column($exer,'name');
+			if ($ex) {
+				$exercise_name = implode(';', $ex);
+			}
+		}
+		$release = Dever::db('agent/option_release')->find($info['release_id']);
+		$release_name = '';
+		if ($release && $release['name']) {
+			$release_name = $release['name'];
+		}
 		$result = array();
 
         $result['期权记录详情'] = array
@@ -84,8 +106,18 @@ Class Option_account{
                 array
             	(
             		array('记录类型', $type_name),
-	                array('资金记录明细', $info_price),
-	                array('行权说明', '行权3年期。自门店注册日期开始计算。满一年30%,满两年35%,满三年35%'),
+	                array('开店投入金额', $info['price'].'元'),
+	                array('零售店政策', $policy_name),
+            	),
+            	array
+            	(
+            		array('政策对应期权价值', $info['zh_price']),
+	                array('实际补贴期权价值', $info['zj_price']),
+	                array('行权条件', $exercise_name),
+            	),
+            	array
+            	(
+            		array('释放比例', $release_name),
             	),
             ),
         );
@@ -102,7 +134,9 @@ Class Option_account{
             	),
                 array
             	(
+            		array('受益人邮箱', $info['email']),
             		array('门店地址', $area.$info['address']),
+            		array('门店编号', $info['number']),
             	),
             ),
         );
@@ -139,7 +173,7 @@ Class Option_account{
 	            	array
 	            	(
 	            		array('审核状态', $audit_type),
-	            		array('确认期权数', $info['num']),
+	            		// array('确认期权数', $info['num']),
 	            		array('审核备注', $info['audit_desc']),
 	            	),
 	            	array
@@ -163,7 +197,7 @@ Class Option_account{
             );
         }
         if (Dever::load('manage/auth')->checkFunc('agent.option_account', 'edit1', '修改资料')) {
-            $purl = Dever::url('project/database/update?project=agent&table=option_account&where_id='.$info['id'].'&audit='.$info['audit'].'&col=name,mobile,idcard,area,address,title,remark,type,price,zh_price,zj_price,other_price','manage');
+            $purl = Dever::url('project/database/update?project=agent&table=option_account&where_id='.$info['id'].'&audit='.$info['audit'].'&col=name,mobile,idcard,area,address,title,remark,type,price,zh_price,zj_price,policy_id,exercise_id,release_id','manage');
 
             $button[] = array
             (
@@ -216,11 +250,36 @@ Class Option_account{
 
         return 'reload';
     }
-	public function updateAccount($id,$name,$data){
-		
+	public function updateAccount($id,$name,$data)
+	{
+		$price = Dever::param('price',$data);
+		$zh_price = Dever::param('zh_price',$data);
+		$zj_price = Dever::param('zj_price',$data);
 		$audit = Dever::param('audit',$data);
 		$num = Dever::param('num',$data);
 		$info = Dever::db('agent/option_account')->find($id);
+		if (!$info) {
+			if ($price <= $zh_price){
+				$zj_price = $zh_price;
+			} elseif ($price > $zh_price) {
+				$zj_price = $price - $zh_price;
+			}
+			$w['where_id'] = $id;
+			$w['zj_price'] = $zj_price;
+			// print_R($w);die;
+			Dever::db('agent/option_account')->update($w);
+		}
+		if (!$info['zj_price'] || $info['zj_price'] <=0) {
+			if ($info['price'] <= $info['zh_price']) {
+				$zj_price = $info['zh_price'];
+			} elseif ($info['price'] > $info['zh_price']) {
+				$zj_price = $info['zh_price'] - $info['zh_price'];
+			}
+			$w['where_id'] = $info['id'];
+			$w['zj_price'] = $zj_price;
+			// print_R($w);die;
+			Dever::db('agent/option_account')->update($w);
+		}
 		if($audit){
 			if ($audit == 1) {
 				$where['where_id'] = $id;

+ 5 - 0
service/agent/template/manage/option_policy.php

@@ -0,0 +1,5 @@
+<?php
+
+$view
+->fetch('#show', 'agent/lib/option_account.list')
+->display();