Browse Source

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

Your Name 2 years ago
parent
commit
880c0560eb

+ 24 - 4
service/bill/database/sell.php

@@ -23,7 +23,12 @@ $type = array
 (
     1 => '直推业绩',
     2 => '团队业绩',
-    10 => '手动发放',
+);
+
+$stype = array
+(
+    1 => '自动发放',
+    2 => '手动发放',
 );
 
 return array
@@ -36,6 +41,7 @@ return array
     'set' => array
     (
         'type' => $type,
+        'stype' => $stype,
     ),
     # 数据结构
     'struct' => array
@@ -130,6 +136,20 @@ return array
             'list_order' => 7,
         ),
 
+        'stype'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发放类型',
+            'default'   => '1',
+            'desc'      => '发放类型',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'    => 'checkbox',
+            'option'    => $stype,
+            'list'      => true,
+            'list_order' => 8,
+        ),
+
         'type_id'      => array
         (
             'type'      => 'int-11',
@@ -234,7 +254,7 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                //'type' => array('yes', 'in'),
+                'type' => array('yes', 'in'),
                 'state' => 1,
             ),
             'type' => 'all',
@@ -247,10 +267,10 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                //'start' => array('yes-cdate', '>='),
+                'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
                 'mid' => 'yes',
-                //'type' => array('yes', 'in'),
+                'type' => array('yes', 'in'),
                 'state' => 1,
             ),
             'type' => 'one',

+ 1 - 1
service/bill/lib/Cron.php

@@ -12,7 +12,7 @@ class Cron
         $month = Dever::input('month', date('Y-m'));
         $start_time = $month .'-01 00:00:00';
 		$end_time = date('Y-m-d', strtotime($start_time. ' +1 month -1 day')).' 23:59:59';
-		$where['type'] = '2,10';
+		$where['type'] = '2';
         $where['start'] = Dever::maketime($start_time);
         $where['end'] = Dever::maketime($end_time);
         $data = Dever::db('bill/sell')->getNumByTime($where);

+ 2 - 1
service/bill/lib/Manage.php

@@ -99,7 +99,8 @@ class Manage
         if ($mid && $num && $desc) {
         	$member = Dever::db('agent/member')->find($mid);
         	if ($member && $member['status'] == 2) {
-        		Dever::load('bill/lib/sell')->up($mid, 10, $num, $member['role'], $id, $desc);
+        		Dever::load('bill/lib/sell')->up($mid, 1, $num, $member['role'], $id, $desc, 2);
+                Dever::load('bill/lib/sell')->up($mid, 2, $num, $member['role'], $id, $desc, 2);
         		$where['where_id'] = $mid;
         		$where['group_sell'] = $num;
         		$where['sell'] = $num;

+ 2 - 1
service/bill/lib/Sell.php

@@ -6,7 +6,7 @@ use Dever;
 
 class Sell
 {
-    public function up($mid, $type, $num, $role, $type_id, $desc)
+    public function up($mid, $type, $num, $role, $type_id, $desc, $stype = 1)
     {
         if ($num == 0) {
             return;
@@ -17,6 +17,7 @@ class Sell
             $desc = $desc[0];
             $where['mid'] = $mid;
             $where['type'] = $type;
+            $where['stype'] = $stype;
             $where['type_id'] = $type_id;
             $where['clear'] = true;
             $info = Dever::db('bill/sell')->find($where);

+ 1 - 1
service/option/database/member.php

@@ -122,7 +122,7 @@ return array
             'default'   => '',
             'desc'      => '身份证号码',
             'match'     => Dever::rule('idcard'),
-            //'match'     => 'is_string',
+            'match'     => 'is_string',
             'search'    => 'fulltext',
             'update'    => 'text',
             'list'      => true,

+ 2 - 0
service/option/lib/Cash.php

@@ -73,6 +73,7 @@ class Cash
                         if ($alert) {
                             Dever::alert('交付期权价值不足发放');
                         } else {
+                            return false;
                             $data['status'] = 2;
                         }
                     }
@@ -83,6 +84,7 @@ class Cash
                         if ($alert) {
                             Dever::alert('发放期权价值不足兑付');
                         } else {
+                            return false;
                             $data['status'] = 2;
                         }
                     }

+ 126 - 41
service/option/lib/Import.php

@@ -12,7 +12,7 @@ class Import
     public function get_api()
     {
         Dever::config('base')->hook = true;
-        $file = Dever::data() . 'q.xlsx';
+        $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 1, 5, 'excel');
 
@@ -26,6 +26,10 @@ class Import
         $table_status['body'][0][0] = 0;
         $table_status['body'][0][1] = 0;
 
+        $table_error = array();
+        $table_error['head'] = array('序列号', '说明');
+        $table_error['body'] = array();
+
         $check = array();
 
         if ($data) {
@@ -56,7 +60,11 @@ class Import
                             $table_status['body'][0][1] += 1;
                         }
                     }
-                    $check[$key] = 2;
+                    if (isset($check[$key]) && $check[$key] == 1) {
+
+                    } else {
+                        $check[$key] = 2;
+                    }
                     if ($id && $update['main'] == 1) {
                         $check[$key] = 1;
                         if (!isset($member[$key])) {
@@ -97,6 +105,18 @@ class Import
             'type' => 'table',
             'content' => $table,
         );
+
+        foreach ($check as $k => $v) {
+            if ($v == 2) {
+                $table_error['body'][$k] = array($k, '无主账号');
+            }
+        }
+        $result['数据异常'] = array
+        (
+            'type' => 'table',
+            'content' => $table_error,
+        );
+
         $html = Dever::show('', $result, false, false);
         return $html;
     }
@@ -105,7 +125,7 @@ class Import
     public function check_api()
     {
         Dever::config('base')->hook = true;
-        $file = Dever::data() . 'q.xlsx';
+        $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 1, 5, 'excel');
 
@@ -129,7 +149,12 @@ class Import
                     $key = $v['A'];
                     $update = array();
                     $update['main'] = $v['E'] == 1 ? 1 : 2;
-                    $check[$key] = 2;
+                    if (isset($check[$key]) && $check[$key] == 1) {
+
+                    } else {
+                        $check[$key] = 2;
+                    }
+                    
                     if ($update['main'] == 1) {
                         $check[$key] = 1;
                         $table_status['body'][0][0] += 1;
@@ -148,18 +173,19 @@ class Import
                 }
             }
         }
+
         $result['数据统计'] = array
         (
             'type' => 'table',
             'content' => $table_status,
         );
 
+
         foreach ($check as $k => $v) {
             if ($v == 2) {
-                $table[$k] = array($k, '无主账号');
+                $table['body'][$k] = array($k, '无主账号');
             }
         }
-
         $result['数据异常'] = array
         (
             'type' => 'table',
@@ -174,6 +200,8 @@ class Import
     {
         Dever::config('base')->hook = true;
 
+        $check = Dever::input('check');
+
         $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 2, 5, 'excel');
@@ -182,38 +210,54 @@ class Import
         $table['head'] = array('手机号', '身份证号', '交付金额', '期权类型', '说明');
         $table['body'] = array();
 
-        $error_table = array();
-        $error_table['head'] = array('手机号', '身份证号', '交付金额', '期权类型', '说明');
-        $error_table['body'] = array();
+        $table_status = array();
+        $table_status['head'] = array('总条数', '总价值');
+        $table_status['body'] = array();
+        $table_status['body'][0][0] = 0;
+        $table_status['body'][0][1] = 0;
 
         if ($data) {
             foreach ($data as $k => $v) {
                 $state = preg_match(Dever::rule('mobile'), $v['A']);
-                if ($state && $v['C'] > 0) {
-                    $where['mobile'] = $v['A'];
-                    $type_name = $v['D'];
-                    if ($type_name == '期权') {
-                        $type = 1;
-                    } else {
-                        $type = 4;
-                    }
-                    $info = Dever::db('option/member')->find($where);
-                    if ($info) {
-                        $account = Dever::db('option/account')->find($info['aid']);
-                        if ($account && $account['status'] < 3) {
-                            $state = Dever::load('option/lib/cash')->up($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
-                            if ($state) {
-
+                if ($state) {
+                    if ($v['C'] > 0) {
+                        $where['mobile'] = $v['A'];
+                        $type_name = $v['D'];
+                        if ($type_name == '期权') {
+                            $type = 1;
+                        } else {
+                            $type = 4;
+                        }
+                        $info = Dever::db('option/member')->find($where);
+                        if ($info) {
+                            $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($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
+                                }
+                                
+                                if ($state) {
+                                    $table_status['body'][0][0] += 1;
+                                    $table_status['body'][0][1] += $v['C'];
+                                } else {
+                                    $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '导入到数据表失败');
+                                }
                             } else {
-
+                                $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
                             }
+                        } else {
+                            $table['body'][] = array($where['mobile'], $v['B'], $v['C'], $type_name, '未找到期权账户');
                         }
+                    } else {
+                        $table['body'][] = array($v['A'], $v['B'], $v['C'], $v['D'], '交付金额为0');
                     }
                 }
             }
         }
         
-        $result['导入状态'] = array
+        $result['导入成功'] = array
         (
             'type' => 'table',
             'content' => $table_status,
@@ -232,31 +276,72 @@ class Import
     public function get_fafang_api()
     {
         Dever::config('base')->hook = true;
+        $check = Dever::input('check');
         $file = Dever::data() . 'qiquan.xlsx';
 
         $data = Dever::excelImport($file, 3, 5, 'excel');
 
+        $table = array();
+        $table['head'] = array('手机号', '身份证号', '发放金额', '期权类型', '说明');
+        $table['body'] = array();
+
+        $table_status = array();
+        $table_status['head'] = array('总条数', '总价值');
+        $table_status['body'] = array();
+        $table_status['body'][0][0] = 0;
+        $table_status['body'][0][1] = 0;
+
         if ($data) {
             foreach ($data as $k => $v) {
                 $state = preg_match(Dever::rule('mobile'), $v['A']);
-                if ($state && $v['C'] > 0) {
-                    $where['mobile'] = $v['A'];
-                    $type_name = $v['D'];
-                    if ($type_name == '期权') {
-                        $type = 2;
-                    } else {
-                        $type = 5;
-                    }
-                    $info = Dever::db('option/member')->find($where);
-                    if ($info) {
-                        $account = Dever::db('option/account')->find($info['aid']);
-                        if ($account && $account['status'] < 3) {
-                            Dever::load('option/lib/cash')->up($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
+                if ($state) {
+                    if ($v['C'] > 0) {
+                        $where['mobile'] = $v['A'];
+                        $type_name = $v['D'];
+                        if ($type_name == '期权') {
+                            $type = 2;
+                        } else {
+                            $type = 5;
+                        }
+                        $info = Dever::db('option/member')->find($where);
+                        if ($info) {
+                            $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($info['id'], $account['id'], $type, $v['C'], $v['E'], false);
+                                }
+                                if ($state) {
+                                    $table_status['body'][0][0] += 1;
+                                    $table_status['body'][0][1] += $v['C'];
+                                } else {
+                                    $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '导入到数据表失败');
+                                }
+                            } else {
+                                $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
+                            }
+                        } else {
+                            $table['body'][] = array($where['mobile'], $v['B'], $v['C'], $type_name, '未找到期权账户');
                         }
+                    } else {
+                        $table['body'][] = array($v['A'], $v['B'], $v['C'], $v['D'], '发放金额为0');
                     }
-                }
+                } 
             }
         }
-        return 'ok';
+        $result['导入成功'] = array
+        (
+            'type' => 'table',
+            'content' => $table_status,
+        );
+
+        $result['导入异常'] = array
+        (
+            'type' => 'table',
+            'content' => $table,
+        );
+        $html = Dever::show('', $result, false, false);
+        return $html;
     }
 }