rabin 2 years ago
parent
commit
93e93f596e
2 changed files with 224 additions and 0 deletions
  1. 171 0
      service/agent/database/import_cash_log.php
  2. 53 0
      service/agent/lib/Import.php

+ 171 - 0
service/agent/database/import_cash_log.php

@@ -0,0 +1,171 @@
+<?php
+
+$type = array
+(
+	1 => '余额',
+	2 => '团队业绩',
+);
+
+$role = function()
+{
+    $array = array(
+        0 => array
+        (
+            'id' => 0,
+            'name' => '选择角色',
+        ),
+    );
+    $data = Dever::load('setting/role-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'import_cash_log',
+    # 显示给用户看的名称
+    'lang' => '导入记录',
+    'order' => 9,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        '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)',
+            //'list_order' => 1,
+        ),
+
+        'agent-member-name'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '姓名',
+            'default'   => '',
+            'desc'      => '姓名',
+            'match'     => 'is_numeric',
+            'sync'      => array('mid', 'id'),
+            'list'      => true,
+        ),
+
+        'agent-member-mobile'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'is_numeric',
+            'sync'      => array('mid', 'id'),
+            'list'      => true,
+        ),
+
+        'agent-member-role'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '代理角色',
+            'default'   => '',
+            'desc'      => '代理角色',
+            'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'agent/member-all',
+                'col' => 'role',
+                'result' => 'id',
+                'search' => 'mid',
+                'option'    => $role,
+            ),
+            'sync'      => array('mid', 'id'),
+            'list'      => 'Dever::load("setting/role-one#name", "{agent-member-role}")',
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'search'	=> 'select',
+            'option'    => $type,
+            'update'    => 'radio',
+            'control'   => 'type',
+            'list'		=> true,
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '具体数值',
+            'default'   => '',
+            'desc'      => '具体数值',
+            'match'     => 'is_numeric',
+            'update'  	=> 'text',
+            'list'      => 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", {cdate})',
+            //'list_order' => 2,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'edit' => false,
+        'insert' => false,
+        //'delete' => false,
+        'excel' => true,
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 53 - 0
service/agent/lib/Import.php

@@ -731,6 +731,59 @@ class Import
         }
     }
 
+    public function get_cash_api()
+    {
+        # 获取已审核通过、权益已发放的用户
+
+        # 团队业绩
+        $data = $this->db->fetchAll('select * from ims_ewei_shop_member where status = 1 and  prestatus = 1 and isagent = 1 and allcommission > 0 order by id asc ');
+
+        if (!$data) {
+            return false;
+        }
+
+        foreach ($data as $k => $v) {
+            $this->cash_log($v['id'], 2, $v['allcommission']);
+            echo $v['id'];
+            echo "\r\n";
+        }
+
+        # 团队业绩
+        $data = $this->db->fetchAll('select a.*,b.credit2 as bcredit2 from ims_ewei_shop_member as a left join ims_mc_members as b on b.uid = a.uid where a.status = 1 and a.prestatus = 1 and a.isagent = 1 and (b.credit2 > 0 || a.credit2 > 0) order by a.id asc ');
+
+        if (!$data) {
+            return false;
+        }
+
+        foreach ($data as $k => $v) {
+            if ($v['bcredit2'] > 0) {
+                $num = $v['bcredit2'];
+            } else {
+                $num = $v['credit2'];
+            }
+            $this->cash_log($v['id'], 1, $num);
+            echo $v['id'];
+            echo "\r\n";
+        }
+
+        return 'ok';
+    }
+
+    public function cash_log($mid, $type, $num)
+    {
+        # 地区、直推代理人数、团队业绩
+        $data['mid'] = $mid;
+        $data['type'] = $type;
+        $data['num'] = $num;
+        $info = Dever::db('agent/import_cash_log')->find($data);
+        if (!$info) {
+            Dever::db('agent/import_cash_log')->insert($data);
+        } else {
+            $data['where_id'] = $info['id'];
+            Dever::db('agent/import_cash_log')->update($data);
+        }
+    }
+
     # 验证直推代理人数是否正确 agentdownnum
 
     # 导入区域价格