rabin 3 years ago
parent
commit
75c5b444dc

+ 48 - 9
service/option/database/account.php

@@ -126,6 +126,25 @@ return array
             //'list'        => true,
             //'list'        => true,
         ),
         ),
 
 
+        'option-member-company_id'=> array
+        (
+            'name'      => '所属公司',
+            'default'   => '',
+            'desc'      => '所属公司',
+            'match'     => 'option',
+            'search'    => Dever::db('option/member')->config['company'] ? array
+            (
+                'api' => 'option/member-getOne',
+                'col' => 'company_id',
+                'result' => 'id',
+                'search' => 'mid',
+                'option'    => Dever::db('option/member')->config['company'],
+                'top'   => true,
+            ) : false,
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+        ),
+
         'mid'      => array
         'mid'      => array
         (
         (
             'type'      => 'int-11',
             'type'      => 'int-11',
@@ -246,8 +265,9 @@ return array
             ),
             ),
             # 读取另外表的关联方式
             # 读取另外表的关联方式
             'sync'      => array('mid', 'id'),
             'sync'      => array('mid', 'id'),
-            'list'      => $search_auth == 2 ? 'Dever::load("option/lib/account.getCash#daijiaofu", {id})' : false,
-            'list_name' => '待交付',
+            //'list'      => $search_auth == 2 ? 'Dever::load("option/lib/account.getCash#daijiaofu", {id})' : false,
+            'list'      => $search_auth == 2 ? 'Dever::load("option/lib/account.getCashInfo", {id}, {mid})' : false,
+            'list_name' => '账户信息',
             'list_order' => 4,
             'list_order' => 4,
         ),
         ),
 
 
@@ -261,9 +281,9 @@ return array
             'update'    => $col ? 'image' : false,
             'update'    => $col ? 'image' : false,
             'key'       => '8',
             'key'       => '8',
             //'place'     => '660*660',
             //'place'     => '660*660',
-            'list'      => $search_auth == 2 ? 'Dever::load("option/lib/account.getCash#qiquan", {id})' : false,
-            'list_name' => '期权',
-            'list_order' => 5,
+            //'list'      => $search_auth == 2 ? 'Dever::load("option/lib/account.getCash#qiquan", {id})' : false,
+            //'list_name' => '期权',
+            //'list_order' => 5,
         ),
         ),
 
 
         'idcard_back'     => array
         'idcard_back'     => array
@@ -276,9 +296,9 @@ return array
             'update'    => $col ? 'image' : false,
             'update'    => $col ? 'image' : false,
             'key'       => '8',
             'key'       => '8',
             //'place'     => '660*660',
             //'place'     => '660*660',
-            'list'      => $search_auth == 2 ? 'Dever::load("option/lib/account.getCash#yuanshiqiquan", {id})' : false,
-            'list_name' => '原始期权',
-            'list_order' => 6,
+            //'list'      => $search_auth == 2 ? 'Dever::load("option/lib/account.getCash#yuanshiqiquan", {id})' : false,
+            //'list_name' => '原始期权',
+            //'list_order' => 6,
         ),
         ),
 
 
         'idcard_path'      => array
         'idcard_path'      => array
@@ -418,6 +438,25 @@ return array
         ),
         ),
     ),
     ),
 
 
+    # 设置top权限
+    'top' => Dever::db('option/member')->config['top_set'],
+
+    # 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
+    'top_option' => array
+    (
+        array
+        (
+            'value' => Dever::db('option/member')->config['auth'],
+            'col' => 'company_id',
+            'join' => array
+            (
+                'table' => 'option/member',
+                'type' => 'left join',
+                'on' => array('mid', 'id'),
+            ),
+        ),
+    ),
+
     'manage' => array
     'manage' => array
     (
     (
         'insert' => false,
         'insert' => false,
@@ -556,7 +595,7 @@ return array
                 'start' => array('yes-cdate', '>='),
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
                 'end' => array('yes-cdate', '<='),
                 'status' => 'yes',
                 'status' => 'yes',
-                'role' => 'yes',
+                'company' => 'yes',
                 'state' => 1,
                 'state' => 1,
             ),
             ),
             'type' => 'count',
             'type' => 'count',

+ 27 - 0
service/option/database/agreement.php

@@ -29,6 +29,7 @@ if ($aid) {
     $option_aid = $aid;
     $option_aid = $aid;
     $search_auth = Dever::input('search_auth');
     $search_auth = Dever::input('search_auth');
     if ($search_auth) {
     if ($search_auth) {
+        Dever::config('base')->clear_top = 1;
         $option_aid .= '&search_auth=' . $search_auth;
         $option_aid .= '&search_auth=' . $search_auth;
     }
     }
     $button = array
     $button = array
@@ -71,6 +72,19 @@ return array
             //'list'        => true,
             //'list'        => true,
         ),
         ),
 
 
+        'company_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属公司',
+            'default'   => '1',
+            'desc'      => '所属公司',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => Dever::db('option/member')->config['company'],
+            'search'    => Dever::db('option/member')->config['company'] ? 'select' : false,
+            //'list'      => true,
+        ),
+
         'aid'      => array
         'aid'      => array
         (
         (
             'type'      => 'int-11',
             'type'      => 'int-11',
@@ -374,6 +388,19 @@ return array
         ),
         ),
     ),
     ),
 
 
+    # 设置top权限
+    'top' => Dever::db('option/member')->config['top_set'],
+
+    # 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
+    'top_option' => array
+    (
+        array
+        (
+            'value' => Dever::db('option/member')->config['auth'],
+            'col' => 'company_id',
+        ),
+    ),
+
     'alter' => array
     'alter' => array
     (
     (
         5 => array
         5 => array

+ 38 - 0
service/option/database/bill_duifu.php

@@ -64,6 +64,25 @@ return array
             //'list'        => true,
             //'list'        => true,
         ),
         ),
 
 
+        'option-member-company_id'=> array
+        (
+            'name'      => '所属公司',
+            'default'   => '',
+            'desc'      => '所属公司',
+            'match'     => 'option',
+            'search'    => Dever::db('option/member')->config['company'] ? array
+            (
+                'api' => 'option/member-getOne',
+                'col' => 'company_id',
+                'result' => 'id',
+                'search' => 'mid',
+                'option'    => Dever::db('option/member')->config['company'],
+                'top'   => true,
+            ) : false,
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+        ),
+
         'order_num'      => array
         'order_num'      => array
         (
         (
             'type'      => 'varchar-100',
             'type'      => 'varchar-100',
@@ -247,6 +266,25 @@ return array
         ),
         ),
     ),
     ),
 
 
+    # 设置top权限
+    'top' => Dever::db('option/member')->config['top_set'],
+
+    # 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
+    'top_option' => array
+    (
+        array
+        (
+            'value' => Dever::db('option/member')->config['auth'],
+            'col' => 'company_id',
+            'join' => array
+            (
+                'table' => 'option/member',
+                'type' => 'left join',
+                'on' => array('mid', 'id'),
+            ),
+        ),
+    ),
+
     'alter' => array
     'alter' => array
     (
     (
         5 => array
         5 => array

+ 38 - 0
service/option/database/bill_fafang.php

@@ -64,6 +64,25 @@ return array
             //'list'        => true,
             //'list'        => true,
         ),
         ),
 
 
+        'option-member-company_id'=> array
+        (
+            'name'      => '所属公司',
+            'default'   => '',
+            'desc'      => '所属公司',
+            'match'     => 'option',
+            'search'    => Dever::db('option/member')->config['company'] ? array
+            (
+                'api' => 'option/member-getOne',
+                'col' => 'company_id',
+                'result' => 'id',
+                'search' => 'mid',
+                'option'    => Dever::db('option/member')->config['company'],
+                'top'   => true,
+            ) : false,
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+        ),
+
         'order_num'      => array
         'order_num'      => array
         (
         (
             'type'      => 'varchar-100',
             'type'      => 'varchar-100',
@@ -273,6 +292,25 @@ return array
         ),
         ),
     ),
     ),
 
 
+        # 设置top权限
+    'top' => Dever::db('option/member')->config['top_set'],
+
+    # 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
+    'top_option' => array
+    (
+        array
+        (
+            'value' => Dever::db('option/member')->config['auth'],
+            'col' => 'company_id',
+            'join' => array
+            (
+                'table' => 'option/member',
+                'type' => 'left join',
+                'on' => array('mid', 'id'),
+            ),
+        ),
+    ),
+
     'request' => array
     'request' => array
     (
     (
         'getData' => array
         'getData' => array

+ 40 - 2
service/option/database/bill_jiaofu.php

@@ -66,6 +66,25 @@ return array
             //'list'        => true,
             //'list'        => true,
         ),
         ),
 
 
+        'option-member-company_id'=> array
+        (
+            'name'      => '所属公司',
+            'default'   => '',
+            'desc'      => '所属公司',
+            'match'     => 'option',
+            'search'    => Dever::db('option/member')->config['company'] ? array
+            (
+                'api' => 'option/member-getOne',
+                'col' => 'company_id',
+                'result' => 'id',
+                'search' => 'mid',
+                'option'    => Dever::db('option/member')->config['company'],
+                'top'   => true,
+            ) : false,
+            # 读取另外表的关联方式
+            'sync'      => array('mid', 'id'),
+        ),
+
         'order_num'      => array
         'order_num'      => array
         (
         (
             'type'      => 'varchar-100',
             'type'      => 'varchar-100',
@@ -135,9 +154,9 @@ return array
         'cash'      => array
         'cash'      => array
         (
         (
             'type'      => 'decimal-11,2',
             'type'      => 'decimal-11,2',
-            'name'      => '期权操作',
+            'name'      => '账户操作',
             'default'   => '0',
             'default'   => '0',
-            'desc'      => '期权操作',
+            'desc'      => '账户操作',
             'match'     => 'is_numeric',
             'match'     => 'is_numeric',
             //'update'    => 'text',
             //'update'    => 'text',
             'list'      => '"+{cash}"',
             'list'      => '"+{cash}"',
@@ -280,6 +299,25 @@ return array
         'version' => 5,
         'version' => 5,
     ),
     ),
 
 
+    # 设置top权限
+    'top' => Dever::db('option/member')->config['top_set'],
+
+    # 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
+    'top_option' => array
+    (
+        array
+        (
+            'value' => Dever::db('option/member')->config['auth'],
+            'col' => 'company_id',
+            'join' => array
+            (
+                'table' => 'option/member',
+                'type' => 'left join',
+                'on' => array('mid', 'id'),
+            ),
+        ),
+    ),
+
     'manage' => array
     'manage' => array
     (
     (
         'insert' => false,
         'insert' => false,

+ 13 - 1
service/option/database/cash.php

@@ -1,5 +1,6 @@
 <?php
 <?php
 
 
+/*
 $type = array
 $type = array
 (
 (
     1 => '期权账户',
     1 => '期权账户',
@@ -7,7 +8,18 @@ $type = array
     3 => '岗位期权账户',
     3 => '岗位期权账户',
     4 => '奖励期权账户',
     4 => '奖励期权账户',
 );
 );
+*/
 
 
+$type = function()
+{
+    $array = array();
+    $data = Dever::load('option/lib/manage.getQiquan');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
 
 
 return array
 return array
 (
 (
@@ -193,7 +205,7 @@ return array
             ),
             ),
             'group' => 'type',
             'group' => 'type',
             'order' => array('daijiaofu_date' => 'desc', 'id' => 'desc'),
             'order' => array('daijiaofu_date' => 'desc', 'id' => 'desc'),
-            'col' => '*,sum(daijiaofu) as daijiaofu, sum(jiaofu) as jiaofu, sum(fafang) as fafang, sum(duifu) as duifu',
+            'col' => '*,sum(daijiaofu) as daijiaofu, sum(jiaofu) as jiaofu, sum(fafang) as fafang, sum(duifu) as duifu|type',
         ),
         ),
 
 
         'upCash_daijiaofu' => array
         'upCash_daijiaofu' => array

+ 160 - 0
service/option/database/company.php

@@ -0,0 +1,160 @@
+<?php
+
+# 常用的col
+$col = '*';
+return array
+(
+    # 表名
+    'name' => 'company',
+    # 显示给用户看的名称
+    'lang' => '期权公司管理',
+    'order' => -100,
+    'end' => array
+	(
+		'insert' => array
+		(
+			'manage/top.sync',
+		),
+		'update' => array
+		(
+			'manage/top.sync',
+		),
+	),
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '公司名称',
+            'default'   => '',
+            'desc'      => '公司名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+            'search'    => 'fulltext',
+        ),
+
+        'agreement_name'      => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '合同名称-变量说明:{name}是代理商姓名,{role}代理商角色,{area}签署地区,{date}签署时间',
+            'default'   => '',
+            'desc'      => '合同名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'option-company_qiquan'=> array
+		(
+			'name' 		=> '期权类型设置',
+			'default' 	=> '',
+			'desc' 		=> '期权类型设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'company_id'),
+			# 根据category字段的值,获取product/attr.search接口的内容
+			'update'	=> array(1),
+		),
+
+		/*
+        'qiquan'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '期权类型设置',
+            'default'   => '',
+            'desc'      => '期权类型设置',
+            'match'     => 'is_string',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'name',
+                    'name'      => '类型名称',
+                    'default'   => '',
+                    'desc'      => '类型名称',
+                    'match'     => 'is_string',
+                    'update'    => 'textarea',
+                ),
+            ),
+        ),
+        */
+        
+        '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", {cdate})',
+        ),
+    ),
+
+    'top' => array
+	(
+		# 数据来源
+		'data' => 'find',
+		# 菜单名
+		'name' => '期权公司设置',
+		# 默认值
+		'value' => 1,
+		# 对应的字段值,设置这个之后,所有设置等于这个值的字段,都要遵循这个权限的控制
+		'key' => 'option/company_id',
+		# 本表中代表名称的字段
+		'col' => 'name',
+	),
+
+	'default' => array
+    (
+        'col' => 'id,name,state,cdate',
+        'value' => array
+        (
+            '1,"代理商", 1,' . DEVER_TIME,
+        ),
+    ),
+    
+    # 管理功能
+    'manage' => array
+    (
+       'delete' => false,
+    ),
+
+    'request' => array
+    (
+        'getIds' => array
+        (
+            'type' => 'all',
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'state' => 1,
+            ),
+            'order' => array('id' => 'desc'),
+            'col' => '*|id',
+        ),
+    ),
+);

+ 92 - 0
service/option/database/company_qiquan.php

@@ -0,0 +1,92 @@
+<?php
+
+# 常用的col
+$col = '*';
+return array
+(
+    # 表名
+    'name' => 'company_qiquan',
+    # 显示给用户看的名称
+    'lang' => '期权类型配置',
+    'order' => -100,
+    'menu' => false,
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+
+        'company_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属公司',
+            'default'   => '-1',
+            'desc'      => '所属公司',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'		=> Dever::input('search_option_company_id'),
+            //'list'      => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '期权类型名称',
+            'default'   => '',
+            'desc'      => '期权类型名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+            'search'    => 'fulltext',
+        ),
+        
+        '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", {cdate})',
+        ),
+    ),
+
+    'default' => array
+    (
+        'col' => 'id,name,company_id,state,cdate',
+        'value' => array
+        (
+            '1,"期权", 1, 1,' . DEVER_TIME,
+            '2,"原始期权", 1, 1,' . DEVER_TIME,
+        ),
+    ),
+    
+    # 管理功能
+    'manage' => array
+    (
+       
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 38 - 29
service/option/database/member.php

@@ -18,29 +18,28 @@ $idcard_bind = array
     2 => '身份证未绑定',
     2 => '身份证未绑定',
 );
 );
 
 
-$role = array
-(
-    1 => '代理商',
-    2 => '公司员工',
-);
-
 # 获取公司权限
 # 获取公司权限
-$auth = Dever::tops();
-$company = function() use ($auth)
-{
-    $array = array();
-    if ($auth) {
-        $info = Dever::db('option/company')->getIds(array('ids' => $auth));
-    } else {
-        $info = Dever::db('option/company')->state();
-    }
-    
-    if($info)
+$top = 'option/company_id';
+$auth = Dever::tops($top);
+$company = array();
+if (!$auth || ($auth && strstr($auth, ','))) {
+    $company = function()
     {
     {
-        $array += $info;
-    }
-    return $array;
-};
+        $array = array();
+        $auth = Dever::tops('option/company_id');
+        if ($auth) {
+            $info = Dever::db('option/company')->getIds(array('ids' => $auth));
+        } else {
+            $info = Dever::db('option/company')->state();
+        }
+        
+        if($info)
+        {
+            $array += $info;
+        }
+        return $array;
+    };
+}
 
 
 $search_auth = Dever::input('search_option_dever_auth', 1);
 $search_auth = Dever::input('search_option_dever_auth', 1);
 
 
@@ -50,8 +49,8 @@ if ($search_auth <= 2) {
     $list_button = array
     $list_button = array
     (
     (
         //'list' => array('查看详情', '"cash&mid={id}&page_type=1&search_audit=-1"'),
         //'list' => array('查看详情', '"cash&mid={id}&page_type=1&search_audit=-1"'),
-        'fast_add' => array('期权价值交付', 'push_cash&search_option_aid={aid}&search_option_mid={id}&type=1'),
-        'fast_add1' => array('期权价值发放', 'push_cash&search_option_aid={aid}&search_option_mid={id}type=2'),
+        'fast_add' => array('期权价值交付', 'push_cash&search_option_aid={aid}&search_option_mid={id}&search_option_company_id={company_id}&type=1'),
+        'fast_add1' => array('期权价值发放', 'push_cash&search_option_aid={aid}&search_option_mid={id}&search_option_company_id={company_id}&type=2'),
         'list1' => array('交付记录', '"bill_jiaofu&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
         'list1' => array('交付记录', '"bill_jiaofu&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
         'list2' => array('发放记录', '"bill_fafang&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
         'list2' => array('发放记录', '"bill_fafang&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
         'list3' => array('兑付记录', '"bill_duifu&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
         'list3' => array('兑付记录', '"bill_duifu&search_option_main=2&search_option_aid={aid}&search_option_mid={id}&top_table=account"'),
@@ -67,6 +66,9 @@ return array
     'order' => 100,
     'order' => 100,
     'menu' => false,
     'menu' => false,
     'check' => 'key,mobile',
     'check' => 'key,mobile',
+    'company' => $company,
+    'auth' => $auth,
+    'top_set' => $top,
     'start' => array
     'start' => array
     (
     (
         'insert' => 'option/lib/manage.checkMember',
         'insert' => 'option/lib/manage.checkMember',
@@ -106,7 +108,7 @@ return array
             'match'     => 'is_numeric',
             'match'     => 'is_numeric',
             'update'    => 'select',
             'update'    => 'select',
             'option'    => $company,
             'option'    => $company,
-            'search'    => 'select',
+            //'search'    => $company ? 'select' : false,
             //'list'      => true,
             //'list'      => true,
         ),
         ),
 
 
@@ -196,14 +198,14 @@ return array
             'option'    => $idcard_bind,
             'option'    => $idcard_bind,
         ),
         ),
 
 
-        'role'        => array
+        'company'        => array
         (
         (
             'type'      => 'int-11',
             'type'      => 'int-11',
-            'name'      => '角色',
+            'name'      => '公司',
             'default'   => '1',
             'default'   => '1',
-            'desc'      => '角色',
+            'desc'      => '公司',
             'match'     => 'is_numeric',
             'match'     => 'is_numeric',
-            'option'    => $role,
+            'option'    => $company,
         ),
         ),
 
 
         'status'        => array
         'status'        => array
@@ -250,7 +252,7 @@ return array
     ),
     ),
 
 
     # 设置top权限
     # 设置top权限
-    'top' => 'option/company_id',
+    //'top' => $top,
 
 
     # 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
     # 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
     'top_option' => array
     'top_option' => array
@@ -283,6 +285,7 @@ return array
             'option' => array
             'option' => array
             (
             (
                 'main' => 1,
                 'main' => 1,
+                'company_id' => 'yes',
                 'key' => 'yes',
                 'key' => 'yes',
                 'mobile' => array('yes', 'like'),
                 'mobile' => array('yes', 'like'),
                 'name' => array('yes', 'like'),
                 'name' => array('yes', 'like'),
@@ -298,6 +301,7 @@ return array
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
             (
             (
+                'company_id' => 'yes',
                 'main' => 'yes',
                 'main' => 'yes',
                 'key' => 'yes',
                 'key' => 'yes',
                 'state' => 1,
                 'state' => 1,
@@ -312,6 +316,7 @@ return array
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
             (
             (
+                'company_id' => 'yes',
                 'main' => 'yes',
                 'main' => 'yes',
                 'state' => 1,
                 'state' => 1,
             ),
             ),
@@ -326,6 +331,7 @@ return array
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
             (
             (
+                'company_id' => 'yes',
                 'mobile' => 'yes',
                 'mobile' => 'yes',
                 'key' => 'yes',
                 'key' => 'yes',
                 'main' => 1,
                 'main' => 1,
@@ -341,6 +347,7 @@ return array
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
             (
             (
+                'company_id' => 'yes',
                 'mobile' => 'yes',
                 'mobile' => 'yes',
                 'key' => 'yes',
                 'key' => 'yes',
                 'main' => 2,
                 'main' => 2,
@@ -355,6 +362,7 @@ return array
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
             (
             (
+                'company_id' => 'yes',
                 'main' => 1,
                 'main' => 1,
                 'start' => array('yes-key', '>='),
                 'start' => array('yes-key', '>='),
                 'end' => array('yes-key', '<='),
                 'end' => array('yes-key', '<='),
@@ -370,6 +378,7 @@ return array
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
             (
             (
+                'company_id' => 'yes',
                 'state' => 1,
                 'state' => 1,
             ),
             ),
             // 'order' => array('id' => 'desc'),
             // 'order' => array('id' => 'desc'),

+ 21 - 21
service/option/database/push_cash.php

@@ -2,30 +2,19 @@
 
 
 $aid = Dever::input('search_option_aid');
 $aid = Dever::input('search_option_aid');
 $mid = Dever::input('search_option_mid');
 $mid = Dever::input('search_option_mid');
+$company_id = Dever::input('search_option_company_id', 1);
 
 
 $option_type = Dever::input('type');
 $option_type = Dever::input('type');
 if ($option_type == 1) {
 if ($option_type == 1) {
-    $type = array
-    (
-        1 => '期权交付',
-        //2 => '期权发放',
-        //3 => '期权兑付',
-        4 => '原始期权交付',
-        //5 => '原始期权发放',
-        //6 => '原始期权兑付',
-    );
-    $type_value = '1';
+    $type = function() use($company_id) {
+        return Dever::load('option/lib/manage')->getQiquan($company_id, '交付');
+    };
+    $stype = 'jiaofu';
 } else {
 } else {
-    $type = array
-    (
-        //1 => '期权交付',
-        2 => '期权发放',
-        //3 => '期权兑付',
-        //4 => '原始期权交付',
-        5 => '原始期权发放',
-        //6 => '原始期权兑付',
-    );
-    $type_value = '2';
+    $type = function() use($company_id) {
+        return Dever::load('option/lib/manage')->getQiquan($company_id, '发放');
+    };
+    $stype = 'fafang';
 }
 }
 
 
 $status = array
 $status = array
@@ -86,13 +75,24 @@ return array
         (
         (
             'type'      => 'tinyint-1',
             'type'      => 'tinyint-1',
             'name'      => '操作类型',
             'name'      => '操作类型',
-            'default'   => $type_value,
+            'default'   => '0',
             'desc'      => '操作类型',
             'desc'      => '操作类型',
             'match'     => 'is_numeric',
             'match'     => 'is_numeric',
             'option'    => $type,
             'option'    => $type,
             'update'    => 'radio',
             'update'    => 'radio',
         ),
         ),
 
 
+        'stype'        => array
+        (
+            'type'      => 'varchar-10',
+            'name'      => '交付类型',
+            'default'   => '0',
+            'desc'      => '交付类型',
+            'match'     => 'is_string',
+            'value'    => $stype,
+            'update'    => 'hidden',
+        ),
+
         'cash'      => array
         'cash'      => array
         (
         (
             'type'      => 'decimal-11,2',
             'type'      => 'decimal-11,2',

+ 47 - 5
service/option/lib/Account.php

@@ -155,18 +155,21 @@ class Account
         $mid = Dever::input('mid');
         $mid = Dever::input('mid');
 
 
         if ($mid) {
         if ($mid) {
-            $member = Dever::db('option/member')->one($mid);
+            $member = Dever::db('option/member')->one(array('id' => $mid, 'clear_top' => true));
             $aid = $member['aid'];
             $aid = $member['aid'];
         }
         }
+
         
         
         $account = Dever::db('option/account')->one($aid);
         $account = Dever::db('option/account')->one($aid);
         if (!$mid) {
         if (!$mid) {
-            $member = Dever::db('option/member')->one($account['mid']);
+            $member = Dever::db('option/member')->one(array('id' => $account['mid'], 'clear_top' => true));
         }
         }
 
 
         $config = Dever::db('option/account')->config['set'];
         $config = Dever::db('option/account')->config['set'];
         $member_config = Dever::db('option/member')->config['set'];
         $member_config = Dever::db('option/member')->config['set'];
 
 
+
+
         $result['账户信息'] = $this->getMemberInfo($member, $member_config);
         $result['账户信息'] = $this->getMemberInfo($member, $member_config);
 
 
         $search_auth = Dever::input('search_auth');
         $search_auth = Dever::input('search_auth');
@@ -208,7 +211,7 @@ class Account
             );
             );
 
 
             # 获取账户资金
             # 获取账户资金
-            $cash_type = Dever::db('option/cash')->config['config_type'];
+            $cash_type = Dever::load('option/lib/manage')->getQiquan($member['company_id']);
             $cash = Dever::db('option/cash')->getTotal(array('aid' => $aid));
             $cash = Dever::db('option/cash')->getTotal(array('aid' => $aid));
 
 
             if ($cash) {
             if ($cash) {
@@ -221,7 +224,7 @@ class Account
                     //$weifafang = number_format($total-$v['fafang']-$v['duifu'], 2);
                     //$weifafang = number_format($total-$v['fafang']-$v['duifu'], 2);
                     $table['body'][] = array
                     $table['body'][] = array
                     (
                     (
-                        $cash_type[$v['type']],
+                        $cash_type[$v['type']]['name'],
                         $v['daijiaofu'],
                         $v['daijiaofu'],
                         $total,
                         $total,
                         //$v['jiaofu'],
                         //$v['jiaofu'],
@@ -370,6 +373,7 @@ class Account
     {
     {
         $result = array();
         $result = array();
 
 
+        $company = Dever::db('option/company')->one($member['company_id']);
         $result = array
         $result = array
         (
         (
             'type' => 'info',
             'type' => 'info',
@@ -379,7 +383,7 @@ class Account
                 (
                 (
                     array('账户类型', $member_config['main'][$member['main']]),
                     array('账户类型', $member_config['main'][$member['main']]),
                     array('账户索引', $member['key']),
                     array('账户索引', $member['key']),
-                    
+                    array('所属公司', $company['name']),
                 ),
                 ),
 
 
                 array
                 array
@@ -460,6 +464,44 @@ class Account
         }
         }
         return array('daijiaofu' => $daijiaofu, 'qiquan' => $qiquan, 'yuanshiqiquan' => $yuanshiqiquan);
         return array('daijiaofu' => $daijiaofu, 'qiquan' => $qiquan, 'yuanshiqiquan' => $yuanshiqiquan);
     }
     }
+
+    public function getCashInfo($id, $mid)
+    {
+        $table = array();
+        $table['head'] = array('账户类型', '待交付', '未发放', '已发放', '已兑付');
+        $table['body'] = array();
+
+        $member = Dever::db('option/member')->find($mid);
+        if ($member) {
+            $cash = Dever::db('option/cash')->getTotal(array('aid' => $id, 'status' => 2));
+
+            $qiquan = Dever::db('option/company_qiquan')->select(array('company_id' => $member['company_id']));
+
+            if ($qiquan) {
+                foreach ($qiquan as $k => $v) {
+                    if (isset($cash[$v['id']])) {
+                        $data = $cash[$v['id']];
+                        $table['body'][$k] = array
+                        (
+                            $v['name'], $data['daijiaofu'], $data['jiaofu'], $data['fafang'], $data['duifu']
+                        );
+                    }
+                }
+            }
+        }
+        $body[''] = array
+        (
+            'type' => 'table',
+            'content' => $table,
+        );
+
+        if ($table['body']) {
+            return Dever::show('', $body);
+        } else {
+            return '暂无';
+        }
+    }
+
     public function send_sms($mid){
     public function send_sms($mid){
         $member = Dever::db('option/member')->one($mid);
         $member = Dever::db('option/member')->one($mid);
         $table = 'template';
         $table = 'template';

+ 146 - 11
service/option/lib/Agreement.php

@@ -39,6 +39,10 @@ class Agreement
         if ($status == 1) {
         if ($status == 1) {
             $info = Dever::db('option/account')->find($id);
             $info = Dever::db('option/account')->find($id);
             $member = Dever::db('option/member')->find($info['mid']);
             $member = Dever::db('option/member')->find($info['mid']);
+            $company = Dever::db('option/company')->one($member['company_id']);
+            if (!$company) {
+                Dever::alert('所属公司不存在');
+            }
             $info['name'] = $member['name'];
             $info['name'] = $member['name'];
             $info['mobile'] = $member['mobile'];
             $info['mobile'] = $member['mobile'];
             $info['idcard'] = $member['idcard'];
             $info['idcard'] = $member['idcard'];
@@ -50,6 +54,10 @@ class Agreement
             if (!$info) {
             if (!$info) {
                 Dever::alert('未生成合同');
                 Dever::alert('未生成合同');
             }
             }
+            $company = Dever::db('option/company')->one($info['company_id']);
+            if (!$company) {
+                Dever::alert('所属公司不存在');
+            }
             $info['create_state'] = 1;
             $info['create_state'] = 1;
             $agreement_id = $info['agreement_id'];
             $agreement_id = $info['agreement_id'];
         }
         }
@@ -57,6 +65,7 @@ class Agreement
         if (!$agreement) {
         if (!$agreement) {
             Dever::alert('合同模板不存在');
             Dever::alert('合同模板不存在');
         }
         }
+        $agreement['name'] = $company['agreement_name'];
 
 
         if ($aid && $aid != $info['aid']) {
         if ($aid && $aid != $info['aid']) {
             //Dever::alert('您没有权限查看');
             //Dever::alert('您没有权限查看');
@@ -75,7 +84,7 @@ class Agreement
             $info['jiaofu_yuanshi'] = $p['yuanshi'];
             $info['jiaofu_yuanshi'] = $p['yuanshi'];
         }
         }
 
 
-        $method = 'pdf_' . $agreement['type'];
+        $method = 'pdf_' . $agreement['type'] . '_' . $company['id'];
         return $this->$method($agreement, $info);
         return $this->$method($agreement, $info);
     }
     }
 
 
@@ -151,15 +160,21 @@ class Agreement
     public function up($account, $date, $total, $qiquan, $yuanshi, $status = 1)
     public function up($account, $date, $total, $qiquan, $yuanshi, $status = 1)
     {
     {
         $member = Dever::db('option/member')->find($account['mid']);
         $member = Dever::db('option/member')->find($account['mid']);
+        $company = Dever::db('option/company')->one($member['company_id']);
+        if (!$company) {
+            Dever::alert('所属公司不存在');
+        }
         $agreement = Dever::db('setting/agreement')->find(array('type' => 6));
         $agreement = Dever::db('setting/agreement')->find(array('type' => 6));
         if (!$agreement) {
         if (!$agreement) {
             Dever::alert('协议模板不存在');
             Dever::alert('协议模板不存在');
         }
         }
+        $agreement['name'] = $company['agreement_name'];
         $qdate = time();
         $qdate = time();
         $sdate = $qdate;
         $sdate = $qdate;
         $edate = strtotime('+3 year', $sdate);
         $edate = strtotime('+3 year', $sdate);
         $where['aid'] = $account['id'];
         $where['aid'] = $account['id'];
         $where['agreement_id'] = $agreement['id'];
         $where['agreement_id'] = $agreement['id'];
+        $where['company_id'] = $company['id'];
         $where['jiaofu_total'] = $total;
         $where['jiaofu_total'] = $total;
         $where['jiaofu_qiquan'] = $qiquan;
         $where['jiaofu_qiquan'] = $qiquan;
         $where['jiaofu_yuanshi'] = $yuanshi;
         $where['jiaofu_yuanshi'] = $yuanshi;
@@ -184,7 +199,7 @@ class Agreement
         $where['status'] = 1;
         $where['status'] = 1;
         $where['audit'] = 2;
         $where['audit'] = 2;
 
 
-        $method = 'content_' . $agreement['type'];
+        $method = 'content_' . $agreement['type'] . '_' . $company['id'];
 
 
         if ($info) {
         if ($info) {
             $up = $where;
             $up = $where;
@@ -205,10 +220,12 @@ class Agreement
         $state = false;
         $state = false;
         $info = Dever::db('option/agreement')->find($id);
         $info = Dever::db('option/agreement')->find($id);
         if ($info) {
         if ($info) {
+            Dever::config('base')->clear_top = 1;
             $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
             $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
-
-            if ($agreement) {
-                $method = 'content_' . $agreement['type'];
+            $company = Dever::db('option/company')->one($info['company_id']);
+            if ($agreement && $company) {
+                $agreement['name'] = $company['agreement_name'];
+                $method = 'content_' . $agreement['type'] . '_' . $company['id'];
                 $up = array();
                 $up = array();
                 $up['content'] = Dever::array_encode($this->$method($agreement, $info));
                 $up['content'] = Dever::array_encode($this->$method($agreement, $info));
                 $up['where_id'] = $info['id'];
                 $up['where_id'] = $info['id'];
@@ -223,9 +240,10 @@ class Agreement
     {
     {
         $info = Dever::db('option/agreement')->find($id);
         $info = Dever::db('option/agreement')->find($id);
         if ($info) {
         if ($info) {
+            Dever::config('base')->clear_top = 1;
             $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
             $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
-
-            if ($agreement) {
+            $company = Dever::db('option/company')->one($info['company_id']);
+            if ($agreement && $company) {
                 $state = Dever::db('option/agreement')->update(array('where_id' => $info['id'], 'status' => 3, 'audit' => 4));
                 $state = Dever::db('option/agreement')->update(array('where_id' => $info['id'], 'status' => 3, 'audit' => 4));
                 if ($state) {
                 if ($state) {
                     # 生成新的合同
                     # 生成新的合同
@@ -259,6 +277,7 @@ class Agreement
     public function getOrderId()
     public function getOrderId()
     {
     {
         $where['order_num'] = Dever::order('AG');
         $where['order_num'] = Dever::order('AG');
+        $where['clear_top'] = true;
         $state = Dever::db('option/agreement')->one($where);
         $state = Dever::db('option/agreement')->one($where);
         if (!$state) {
         if (!$state) {
             return $where['order_num'];
             return $where['order_num'];
@@ -272,7 +291,7 @@ class Agreement
         return array('name' => $name, 'content' => $content);
         return array('name' => $name, 'content' => $content);
     }
     }
 
 
-    public function content_6($agreement, $info)
+    public function content_6_1($agreement, $info)
     {
     {
         $content = array();
         $content = array();
 
 
@@ -430,8 +449,7 @@ class Agreement
         return $content;
         return $content;
     }
     }
 
 
-    # 市场管理培训师承诺书
-    public function pdf_6($agreement, $info)
+    public function pdf_6_1($agreement, $info)
     {
     {
         $base = Dever::db('setting/base')->find();
         $base = Dever::db('setting/base')->find();
 
 
@@ -479,7 +497,115 @@ class Agreement
                 $pdf->content($v['name'], $v['content'], $this->font_size);
                 $pdf->content($v['name'], $v['content'], $this->font_size);
             }
             }
         } else {
         } else {
-            $method = 'content_' . $agreement['type'];
+            $method = 'content_' . $agreement['type'] . '_1';
+            $content = $this->$method($agreement, $info);
+
+            foreach ($content as $k => $v) {
+                $pdf->content($v['name'], $v['content'], $this->font_size);
+            }
+
+            if (isset($info['create_state']) && $info['create_state'] == 1) {
+                $up = array();
+                $up['content'] = Dever::array_encode($content);
+                $up['where_id'] = $info['id'];
+                $state = Dever::db('option/agreement')->update($up);
+            }
+        }
+
+        $pdf->AddPage();
+
+
+
+        $pdf->left('兹证明,各方或其授权代表于本协议文首日期签署本协议,以昭信守。');
+
+        $pdf->br();
+
+        $pdf->left('[中食民安(北京)科技有限公司]');
+        $pdf->left('签署:');
+
+        $pdf->br();
+        $pdf->br();
+
+        $pdf->left('期权激励对象:[ '.$info['name'].' ]');
+        $pdf->left('签署:');
+
+        //$base['agreement_sign'] = $info['sign'] = 'https://7.churenyiliao.com/1/2022/01/09/de337334506d64eee2a6ec51c9f7db10.png';
+
+        $pic = Dever::pic($base['agreement_sign']);
+
+        $cx = $pdf->GetX();
+        $cy = $pdf->GetY();
+
+        $x = $cx - 165;
+        $y = $cy - 32;
+
+        if ($pic) {
+            $pdf->Image($pic, $x, $y, 20, 20);
+        }
+
+        $y = $cy;
+
+        if ($info['sign']) {
+            $info['sign'] = Dever::pic($info['sign']);
+            $temp = explode('?', $info['sign']);
+            $info['sign'] = $temp[0];
+            if (strstr($info['sign'], 'http')) {
+                $pdf->Image($info['sign'], $x, $y, 20, 20);
+            }
+        }
+
+        $pdf->out($name);
+    }
+
+    public function pdf_6_2($agreement, $info)
+    {
+        $base = Dever::db('setting/base')->find();
+
+        if (isset($info['jiaofu_date'])) {
+            $info['jiaofu_date'] = date("Y年m月d日", $info['jiaofu_date']);
+        } else {
+            $info['jiaofu_total'] = $info['jiaofu_qiquan'] = $info['jiaofu_yuanshi'] = '0.00';
+            $info['jiaofu_date'] = date("Y年m月d日");
+        }
+
+        if (!isset($info['jiaofu_total'])) {
+            $info['jiaofu_total'] = '0.00';
+        }
+        if (!isset($info['jiaofu_qiquan'])) {
+            $info['jiaofu_qiquan'] = '0.00';
+        }
+        if (!isset($info['jiaofu_yuanshi'])) {
+            $info['jiaofu_yuanshi'] = '0.00';
+        }
+
+        if (isset($info['qdate']) && $info['qdate']) {
+            $qdate = date('Y年m月d日', $info['qdate']);
+        } else {
+            $qdate = date('Y年m月d日');
+        }
+        $name = $this->name($agreement, $info);
+
+        $pdf = Dever::load('pdf/lib/core')->init();
+        $pdf->SetTitle($name);
+        $pdf->setCellHeightRatio(1.8);
+        $pdf->setCellPaddings(10, 0, 10, 0);
+        //$pdf->font(18, 'B');
+        $pdf->font(18);
+        $pdf->center('[中食民安(北京)科技有限公司]');
+        $pdf->center('员工期权激励计划');
+        $pdf->br();
+        $pdf->font($this->font_size);
+
+        $pdf->left('本期权交付协议(“本协议”)由以下双方签署:');
+        $pdf->br();
+
+        if (isset($info['content1']) && $info['content']) {
+            $info['content'] = Dever::array_decode($info['content']);
+            foreach($info['content'] as $k => $v) {
+                $pdf->content($v['name'], $v['content'], $this->font_size);
+            }
+        } else {
+            $method = 'content_' . $agreement['type'] . '_2';
             $content = $this->$method($agreement, $info);
             $content = $this->$method($agreement, $info);
 
 
             foreach ($content as $k => $v) {
             foreach ($content as $k => $v) {
@@ -538,4 +664,13 @@ class Agreement
 
 
         $pdf->out($name);
         $pdf->out($name);
     }
     }
+
+    public function content_6_2($agreement, $info)
+    {
+        $content = array();
+
+        $content[] = $this->content('', '1、[中食民安(北京)科技有限公司](“公司”)是一家按照中华人民共和国(“中国”)法律有效设立并合法存在的有限公司;');
+
+        return $content;
+    }
 }
 }

+ 11 - 23
service/option/lib/Cash.php

@@ -6,22 +6,13 @@ use Dever;
 
 
 class Cash
 class Cash
 {
 {
-    private function getInfo($type, $cash)
+    private function getInfo($type, $stype, $cash)
     {
     {
-        if ($type > 3) {
-            $cash_type = 2;
-        } else {
-            $cash_type = 1;
-        }
-        if ($type == 1 || $type == 4) {
-            $table = 'jiaofu';
-            $prefix = 'J';
-        } elseif ($type == 2 || $type == 5) {
-            $table = 'fafang';
-            $prefix = 'F';
-        } elseif ($type == 3 || $type == 6) {
+        $cash_type = $type;
+        $table = $stype;
+        $prefix = ucwords(substr($table, 0, 1));
+        if ($stype == 'duifu') {
             $table = 'duifu';
             $table = 'duifu';
-            $prefix = 'D';
             $cash = -1*$cash;
             $cash = -1*$cash;
         }
         }
 
 
@@ -42,14 +33,14 @@ class Cash
         return $this->delete(array('to_uid' => $uid, 'level' => 1), array('uid' => $parent));
         return $this->delete(array('to_uid' => $uid, 'level' => 1), array('uid' => $parent));
     }
     }
 
 
-    public function up($aid, $mid, $type, $cash, $desc, $alert = true)
+    public function up($aid, $mid, $type, $stype, $cash, $desc, $alert = true)
     {
     {
         if ($cash == 0) {
         if ($cash == 0) {
             return false;
             return false;
         }
         }
         $account = Dever::db('option/account')->find(array('id' => $aid, 'clear' => true));
         $account = Dever::db('option/account')->find(array('id' => $aid, 'clear' => true));
         if ($account['status'] <= 2) {
         if ($account['status'] <= 2) {
-            list($table, $cash, $cash_type, $prefix) = $this->getInfo($type, $cash);
+            list($table, $cash, $cash_type, $prefix) = $this->getInfo($type, $stype, $cash);
             $where = array();
             $where = array();
             $where['clear'] = true;
             $where['clear'] = true;
             $where['aid'] = $aid;
             $where['aid'] = $aid;
@@ -197,11 +188,8 @@ class Cash
     # 获取详情
     # 获取详情
     private function getOne($data, $name, $audit)
     private function getOne($data, $name, $audit)
     {
     {
-        if ($data['type'] == 1) {
-            $data['type_name'] = '期权' . $name ;
-        } else {
-            $data['type_name'] = '原始期权' . $name;
-        }
+        $qiquan = Dever::db('option/company_qiquan')->one($data['type']);
+        $data['type_name'] = $qiquan['name'] . $name ;
         
         
         $data['audit_name'] = $audit[$data['audit']];
         $data['audit_name'] = $audit[$data['audit']];
         $data['cdate_string'] = date('Y-m-d H:i', $data['cdate']);
         $data['cdate_string'] = date('Y-m-d H:i', $data['cdate']);
@@ -296,7 +284,7 @@ class Cash
         $type = $config['type'][$info['type']];
         $type = $config['type'][$info['type']];
 
 
         $member = Dever::db('agent/member')->find($info['mid']);
         $member = Dever::db('agent/member')->find($info['mid']);
-        $role = Dever::db('setting/role')->one($member['role']);
+        $company = Dever::db('setting/company')->one($member['company']);
         $level = Dever::db('setting/level')->one($member['level_id']);
         $level = Dever::db('setting/level')->one($member['level_id']);
 
 
         if ($member['shop_id']) {
         if ($member['shop_id']) {
@@ -323,7 +311,7 @@ class Cash
                 array
                 array
                 (
                 (
                     array('代理商', $member['name'] . ' ' . $member['mobile']),
                     array('代理商', $member['name'] . ' ' . $member['mobile']),
-                    array('代理角色', $role['name'] . ($level ? '('.$level['name'].')' : '')),
+                    array('代理公司', $company['name'] . ($level ? '('.$level['name'].')' : '')),
                     array('所属店铺', $shop['name']),
                     array('所属店铺', $shop['name']),
                 ),
                 ),
 
 

+ 2 - 1
service/option/lib/Core.php

@@ -12,9 +12,10 @@ class Core
 
 
     public function __construct()
     public function __construct()
     {
     {
+        Dever::config('base')->clear_top = 1;
         $this->uid = Dever::load('passport/user')->check(false);
         $this->uid = Dever::load('passport/user')->check(false);
         if ($this->uid <= 0) {
         if ($this->uid <= 0) {
-            $this->uid = 5;
+            $this->uid = 15;
         }
         }
         $this->checkLogin();
         $this->checkLogin();
         if ($this->uid) {
         if ($this->uid) {

+ 77 - 63
service/option/lib/Import.php

@@ -9,7 +9,7 @@ include('/share/lib/php/dever_package/excel/src/PHPExcel.php');
 class Import
 class Import
 {
 {
     private $path = '/www/churen/data/';
     private $path = '/www/churen/data/';
-    private $name = 'qiquan_2022_06_16_05.xlsx';
+    private $name = 'qiquan_1.xlsx';
     # 导入账户
     # 导入账户
     public function get_api()
     public function get_api()
     {
     {
@@ -19,7 +19,7 @@ class Import
         $data = Dever::excelImport($file, 1, 5, 'excel');
         $data = Dever::excelImport($file, 1, 5, 'excel');
 
 
         $table = array();
         $table = array();
-        $table['head'] = array('序列号', '姓名', '手机号', '身份证号', '说明');
+        $table['head'] = array('序列号', '公司ID', '姓名', '手机号', '身份证号', '说明');
         $table['body'] = array();
         $table['body'] = array();
 
 
         $table_status = array();
         $table_status = array();
@@ -42,6 +42,7 @@ class Import
                     $key = trim($v['A']);
                     $key = trim($v['A']);
                     $where['key'] = trim($v['A']);
                     $where['key'] = trim($v['A']);
                     $where['mobile'] = trim($v['C']);
                     $where['mobile'] = trim($v['C']);
+                    $where['company_id'] = (isset($v['F']) && $v['F']) ? trim($v['F']) : 1;
                     $where['clear'] = true;
                     $where['clear'] = true;
                     $info = Dever::db('option/member')->one($where);
                     $info = Dever::db('option/member')->one($where);
                     $update = $where;
                     $update = $where;
@@ -56,7 +57,7 @@ class Import
                         $id = Dever::db('option/member')->update($update);
                         $id = Dever::db('option/member')->update($update);
                     }
                     }
                     if (!$id) {
                     if (!$id) {
-                        $table['body'][] = array($update['key'], $update['name'], $update['mobile'], $update['idcard'], '账户导入失败,请重新导入');
+                        $table['body'][] = array($update['key'], $update['company_id'], $update['name'], $update['mobile'], $update['idcard'], '账户导入失败,请重新导入');
                     } else {
                     } else {
                         if ($update['main'] == 2) {
                         if ($update['main'] == 2) {
                             $table_status['body'][0][1] += 1;
                             $table_status['body'][0][1] += 1;
@@ -79,7 +80,7 @@ class Import
                             $member[$key] = $account['id'];
                             $member[$key] = $account['id'];
                         }
                         }
                         if (!$member[$key]) {
                         if (!$member[$key]) {
-                            $table['body'][] = array($update['key'], $update['name'], $update['mobile'], $update['idcard'], '生成主账户失败');
+                            $table['body'][] = array($update['key'], $update['company_id'], $update['name'], $update['mobile'], $update['idcard'], '生成主账户失败');
                         } else {
                         } else {
                             $table_status['body'][0][0] += 1;
                             $table_status['body'][0][0] += 1;
                         }
                         }
@@ -152,6 +153,7 @@ class Import
                 if ($state) {
                 if ($state) {
                     $key = $v['A'];
                     $key = $v['A'];
                     $mobile = $v['C'];
                     $mobile = $v['C'];
+                    $company_id = (isset($v['F']) && $v['F']) ? trim($v['F']) : 1;
                     $update = array();
                     $update = array();
                     $update['main'] = $v['E'] == 1 ? 1 : 2;
                     $update['main'] = $v['E'] == 1 ? 1 : 2;
                     if (!isset($check[$key])) {
                     if (!isset($check[$key])) {
@@ -237,7 +239,7 @@ class Import
         $data = Dever::excelImport($file, 2, 5, 'excel');
         $data = Dever::excelImport($file, 2, 5, 'excel');
 
 
         $table = array();
         $table = array();
-        $table['head'] = array('手机号', '身份证号', '交付金额', '期权类型', '说明');
+        $table['head'] = array('公司ID', '手机号', '身份证号', '交付金额', '期权类型', '说明');
         $table['body'] = array();
         $table['body'] = array();
 
 
         $table_status = array();
         $table_status = array();
@@ -248,47 +250,53 @@ class Import
 
 
         if ($data) {
         if ($data) {
             foreach ($data as $k => $v) {
             foreach ($data as $k => $v) {
-                $state = preg_match(Dever::rule('mobile'), $v['A']);
+                $mobile = trim($v['A']);
+                $state = preg_match(Dever::rule('mobile'), $mobile);
                 if ($state) {
                 if ($state) {
+                    $company_id = (isset($v['F']) && $v['F']) ? trim($v['F']) : 1;
                     if ($v['C'] > 0) {
                     if ($v['C'] > 0) {
                         $where['clear'] = true;
                         $where['clear'] = true;
-                        $where['mobile'] = trim($v['A']);
+                        $where['mobile'] = $mobile;
+                        $where['company_id'] = $company_id;
                         $type_name = trim($v['D']);
                         $type_name = trim($v['D']);
-                        if ($type_name == '期权') {
-                            $type = 1;
-                        } else {
-                            $type = 4;
-                        }
-                        $info = Dever::db('option/member')->find($where);
-                        if ($info) {
-                            $idcard = strtoupper(trim($v['B']));
-                            if ($info['idcard'] != $idcard) {
-                                $table['body'][] = array($info['mobile'], $info['idcard'], $idcard, $type_name, '手机号和身份证不对应');
-                            } else {
-                                $account = Dever::db('option/account')->find(array('id' => $info['aid'], 'clear' => true));
-                                if ($account && $account['status'] < 3) {
-                                    if ($check == 1) {
-                                        $state = true;
-                                    } else {
-                                        $state = Dever::load('option/lib/cash')->up($account['id'], $info['id'], $type, $v['C'], $v['E'], false);
-                                    }
-                                    
-                                    if ($state) {
-                                        $table_status['body'][0][0] += 1;
-                                        $table_status['body'][0][1] += $v['C'];
+                        $type_info = Dever::db('option/company_qiquan')->find(array('name' => $type_name, 'company_id' => $where['company_id']));
+                        if ($type_info) {
+                            $type = $type_info['id'];
+
+                            $info = Dever::db('option/member')->find($where);
+                            if ($info) {
+                                $idcard = strtoupper(trim($v['B']));
+                                if ($info['idcard'] != $idcard) {
+                                    $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $idcard, $type_name, '手机号和身份证不对应');
+                                } else {
+                                    $account = Dever::db('option/account')->find(array('id' => $info['aid'], 'clear' => true));
+                                    if ($account && $account['status'] < 3) {
+                                        if ($check == 1) {
+                                            $state = true;
+                                        } else {
+                                            $state = Dever::load('option/lib/cash')->up($account['id'], $info['id'], $type, 'jiaofu', $v['C'], $v['E'], false);
+                                        }
+                                        
+                                        if ($state) {
+                                            $table_status['body'][0][0] += 1;
+                                            $table_status['body'][0][1] += $v['C'];
+                                        } else {
+                                            $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $v['C'], $type_name, '导入到数据表失败');
+                                        }
                                     } else {
                                     } else {
-                                        $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '导入到数据表失败');
+                                        $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
                                     }
                                     }
-                                } else {
-                                    $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
                                 }
                                 }
+                                
+                            } else {
+                                $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $type_name, '未找到期权账户');
                             }
                             }
-                            
                         } else {
                         } else {
-                            $table['body'][] = array($where['mobile'], $v['B'], $v['C'], $type_name, '未找到期权账户');
+                            $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $type_name, '期权类型不存在');
                         }
                         }
+                        
                     } else {
                     } else {
-                        $table['body'][] = array($v['A'], $v['B'], $v['C'], $v['D'], '交付金额为0');
+                        $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $v['D'], '交付金额为0');
                     }
                     }
                 }
                 }
             }
             }
@@ -330,44 +338,50 @@ class Import
 
 
         if ($data) {
         if ($data) {
             foreach ($data as $k => $v) {
             foreach ($data as $k => $v) {
-                $state = preg_match(Dever::rule('mobile'), $v['A']);
+                $mobile = trim($v['A']);
+                $state = preg_match(Dever::rule('mobile'), $mobile);
                 if ($state) {
                 if ($state) {
+                    $company_id = (isset($v['F']) && $v['F']) ? trim($v['F']) : 1;
                     if ($v['C'] > 0) {
                     if ($v['C'] > 0) {
-                        $where['mobile'] = trim($v['A']);
+                        $where['clear'] = true;
+                        $where['mobile'] = $mobile;
+                        $where['company_id'] = $company_id;
                         $type_name = trim($v['D']);
                         $type_name = trim($v['D']);
-                        if ($type_name == '期权') {
-                            $type = 2;
-                        } else {
-                            $type = 5;
-                        }
-                        $info = Dever::db('option/member')->find($where);
-                        if ($info) {
-                            $idcard = strtoupper(trim($v['B']));
-                            if ($info['idcard'] != $idcard) {
-                                $table['body'][] = array($info['mobile'], $info['idcard'], $idcard, $type_name, '手机号和身份证不对应');
-                            } else {
-                                $account = Dever::db('option/account')->find($info['aid']);
-                                if ($account && $account['status'] < 3) {
-                                    if ($check == 1) {
-                                        $state = true;
-                                    } else {
-                                        $state = Dever::load('option/lib/cash')->up($account['id'], $info['id'], $type, $v['C'], $v['E'], false);
-                                    }
-                                    if ($state) {
-                                        $table_status['body'][0][0] += 1;
-                                        $table_status['body'][0][1] += $v['C'];
+                        $type_info = Dever::db('option/company_qiquan')->find(array('name' => $type_name, 'company_id' => $where['company_id']));
+                        if ($type_info) {
+                            $type = $type_info['id'];
+                            $info = Dever::db('option/member')->find($where);
+                            if ($info) {
+                                $idcard = strtoupper(trim($v['B']));
+                                if ($info['idcard'] != $idcard) {
+                                    $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $idcard, $type_name, '手机号和身份证不对应');
+                                } else {
+                                    $account = Dever::db('option/account')->find($info['aid']);
+                                    if ($account && $account['status'] < 3) {
+                                        if ($check == 1) {
+                                            $state = true;
+                                        } else {
+                                            $state = Dever::load('option/lib/cash')->up($account['id'], $info['id'], $type, 'fafang', $v['C'], $v['E'], false);
+                                        }
+                                        if ($state) {
+                                            $table_status['body'][0][0] += 1;
+                                            $table_status['body'][0][1] += $v['C'];
+                                        } else {
+                                            $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $v['C'], $type_name, '交付价值不足');
+                                        }
                                     } else {
                                     } else {
-                                        $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '交付价值不足');
+                                        $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
                                     }
                                     }
-                                } else {
-                                    $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
                                 }
                                 }
+                            } else {
+                                $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $type_name, '未找到期权账户');
                             }
                             }
                         } else {
                         } else {
-                            $table['body'][] = array($where['mobile'], $v['B'], $v['C'], $type_name, '未找到期权账户');
+                            $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $type_name, '期权类型不存在');
                         }
                         }
+                        
                     } else {
                     } else {
-                        $table['body'][] = array($v['A'], $v['B'], $v['C'], $v['D'], '发放金额为0');
+                        $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $v['D'], '发放金额为0');
                     }
                     }
                 } 
                 } 
             }
             }

+ 24 - 6
service/option/lib/Manage.php

@@ -6,10 +6,27 @@ use Dever;
 
 
 class Manage
 class Manage
 {
 {
+    public function getQiquan($company_id = false, $name = '账户')
+    {
+        $where = array();
+        if ($company_id) {
+            $where['company_id'] = $company_id;
+        }
+        $data = Dever::db('option/company_qiquan')->all($where);
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $data[$k]['name'] = $v['name'] . $name;
+            }
+        }
+
+        return $data;
+    }
+
     public function updateMember($id, $name, $data)
     public function updateMember($id, $name, $data)
     {
     {
         Dever::config('base')->hook = true;
         Dever::config('base')->hook = true;
         $where['id'] = $id;
         $where['id'] = $id;
+        $where['clear_top'] = true;
         $where['clear'] = true;
         $where['clear'] = true;
         $info = Dever::db('option/member')->find($where);
         $info = Dever::db('option/member')->find($where);
         if ($info) {
         if ($info) {
@@ -25,7 +42,7 @@ class Manage
                 Dever::db('option/member')->update(array('where_id' => $info['id'], 'aid' => $aid));
                 Dever::db('option/member')->update(array('where_id' => $info['id'], 'aid' => $aid));
             }
             }
 
 
-            $main = Dever::db('option/member')->getMain(array('key' => $info['key']));
+            $main = Dever::db('option/member')->getMain(array('key' => $info['key'], 'company_id' => $info['company_id'], 'clear_top' => true));
             if ($main && $main['aid']) {
             if ($main && $main['aid']) {
                 $where = array();
                 $where = array();
                 $where['option_key'] = $info['key'];
                 $where['option_key'] = $info['key'];
@@ -41,9 +58,9 @@ class Manage
         $main = Dever::param('main', $data);
         $main = Dever::param('main', $data);
 
 
         if ($main && $main == 1) {
         if ($main && $main == 1) {
-            $member = Dever::db('option/member')->find($id);
+            $member = Dever::db('option/member')->find(array('id' => $id, 'clear_top' => true));
             if ($member) {
             if ($member) {
-                $main_member = Dever::db('option/member')->select(array('main' => 1, 'aid' => $member['aid']));
+                $main_member = Dever::db('option/member')->select(array('main' => 1, 'aid' => $member['aid'], 'clear_top' => true));
                 if ($main_member) {
                 if ($main_member) {
                     foreach ($main_member as $k => $v) {
                     foreach ($main_member as $k => $v) {
                         if ($v['id'] != $id) {
                         if ($v['id'] != $id) {
@@ -90,7 +107,7 @@ class Manage
                 }
                 }
             }
             }
 
 
-            $member = Dever::db('option/member')->one($info['mid']);
+            $member = Dever::db('option/member')->one(array('id' => $info['mid'], 'clear_top' => true));
             if ($audit == 3) {
             if ($audit == 3) {
                 if (Dever::project('sms')) {
                 if (Dever::project('sms')) {
                     Dever::load('sms/api')->send('qiquan_reg_yes', $member['mobile'], array('name' => $member['name']));
                     Dever::load('sms/api')->send('qiquan_reg_yes', $member['mobile'], array('name' => $member['name']));
@@ -237,12 +254,13 @@ class Manage
         $aid = Dever::param('aid', $data);
         $aid = Dever::param('aid', $data);
         $mid = Dever::param('mid', $data);
         $mid = Dever::param('mid', $data);
         $type = Dever::param('type', $data);
         $type = Dever::param('type', $data);
+        $stype = Dever::param('stype', $data);
         $cash = Dever::param('cash', $data);
         $cash = Dever::param('cash', $data);
         $desc = Dever::param('desc', $data);
         $desc = Dever::param('desc', $data);
-        if ($aid && $type && $cash && $desc) {
+        if ($aid && $type && $stype && $cash) {
             $account = Dever::db('option/account')->find($aid);
             $account = Dever::db('option/account')->find($aid);
             if ($account && $account['status'] <= 2) {
             if ($account && $account['status'] <= 2) {
-                Dever::load('option/lib/cash')->up($aid, $mid, $type, $cash, $desc);
+                Dever::load('option/lib/cash')->up($aid, $mid, $type, $stype, $cash, $desc);
             } else {
             } else {
                 Dever::db('option/push_cash')->update(array('where_id' => $id, 'status' => 2));
                 Dever::db('option/push_cash')->update(array('where_id' => $id, 'status' => 2));
                 Dever::alert('期权账户已停用或者未审核,操作失败');
                 Dever::alert('期权账户已停用或者未审核,操作失败');

+ 1 - 1
service/option/lib/Member.php

@@ -11,7 +11,7 @@ class Member
         if ($id < 0) {
         if ($id < 0) {
             return '无';
             return '无';
         }
         }
-        $account = Dever::db('option/member')->find($id);
+        $account = Dever::db('option/member')->find(array('id' => $id, 'clear_top' => true));
         if ($account) {
         if ($account) {
             $string = $account['name'] . '<br />' . $account['mobile'] . '<br />' . $account['idcard'] . '<br />' . $account['key'];
             $string = $account['name'] . '<br />' . $account['mobile'] . '<br />' . $account['idcard'] . '<br />' . $account['key'];
 
 

+ 4 - 2
service/option/src/Auth.php

@@ -28,8 +28,10 @@ class Auth
     # 检测登录信息
     # 检测登录信息
     private function checkLogin($state = 1)
     private function checkLogin($state = 1)
     {
     {
+        Dever::config('base')->clear_top = 1;
         $mobile = Dever::load('option/lib/account')->checkMobile(Dever::input('mobile'));
         $mobile = Dever::load('option/lib/account')->checkMobile(Dever::input('mobile'));
-        $user = Dever::db('option/member')->find(array('mobile' => $mobile));
+        $company_id = Dever::input('cid', 1);
+        $user = Dever::db('option/member')->find(array('mobile' => $mobile, 'company_id' => $company_id));
         if (!$user) {
         if (!$user) {
             Dever::alert('手机号不正确');
             Dever::alert('手机号不正确');
         }
         }
@@ -65,7 +67,7 @@ class Auth
                         Dever::alert('身份证号不正确');
                         Dever::alert('身份证号不正确');
                     }
                     }
                     # 验证身份证是否验证过
                     # 验证身份证是否验证过
-                    $find = Dever::db('option/member')->find(array('idcard' => $idcard, 'idcard_bind' => 1));
+                    $find = Dever::db('option/member')->find(array('idcard' => $idcard, 'idcard_bind' => 1, 'company_id' => $company_id));
                     if ($find && $find['id'] != $user['id']) {
                     if ($find && $find['id'] != $user['id']) {
                         Dever::alert('身份证已被绑定');
                         Dever::alert('身份证已被绑定');
                     }
                     }

+ 6 - 10
service/option/src/My.php

@@ -60,13 +60,11 @@ class My extends Core
 
 
         $total = 0;
         $total = 0;
 
 
+        $cash_type = Dever::load('option/lib/manage')->getQiquan($this->user['company_id']);
+
         if ($this->data['cash']) {
         if ($this->data['cash']) {
             foreach ($this->data['cash'] as $k => $v) {
             foreach ($this->data['cash'] as $k => $v) {
-                if ($v['type'] == 1) {
-                    $this->data['cash'][$k]['type_name'] = '期权交付价值';
-                } else {
-                    $this->data['cash'][$k]['type_name'] = '原始期权交付价值';
-                }
+                $this->data['cash'][$k]['type_name'] = $cash_type[$v['type']]['name'] . '交付价值';
                 $total += $v['daijiaofu'];
                 $total += $v['daijiaofu'];
                 $this->data['cash'][$k]['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
                 $this->data['cash'][$k]['total'] = number_format($v['jiaofu'] + $v['fafang'] + $v['duifu'], 2, '.', '');
                 if ($this->data['cash'][$k]['total'] <= 0) {
                 if ($this->data['cash'][$k]['total'] <= 0) {
@@ -106,13 +104,11 @@ class My extends Core
         $date = 0;
         $date = 0;
         $total = $qiquan = $yuanshi = 0;
         $total = $qiquan = $yuanshi = 0;
 
 
+        $cash_type = Dever::load('option/lib/manage')->getQiquan($this->user['company_id']);
+
         if ($this->data['list']) {
         if ($this->data['list']) {
             foreach ($this->data['list'] as $k => $v) {
             foreach ($this->data['list'] as $k => $v) {
-                if ($v['type'] == 1) {
-                    $this->data['list'][$k]['type_name'] = '待交付期权';
-                } else {
-                    $this->data['list'][$k]['type_name'] = '待交付原始期权';
-                }
+                $this->data['list'][$k]['type_name'] = '待交付' . $cash_type[$v['type']]['name'];
                 if ($v['daijiaofu_date'] > $date) {
                 if ($v['daijiaofu_date'] > $date) {
                     $date = $v['daijiaofu_date'];
                     $date = $v['daijiaofu_date'];
                 }
                 }