Browse Source

经济人提现

linwu 1 year ago
parent
commit
ef537c67f8

+ 263 - 265
app/admin/controller/Agent.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace app\admin\controller;
 
 use app\admin\BaseController;
@@ -14,270 +15,267 @@ use think\facade\Db;
 
 class Agent extends BaseController
 {
-	
-	public function agentList()
-	{ 
-		$workerlist = WorkerModel::order(['id'=>'desc'])->select();
-		return view('agent/agentlist',[
-			'workerlist'		=> $workerlist
-		]);
-	}
-	
-	public function agentForm()
-	{
-		$id = input('id/d, 0');
-		$agent = AgentModel::with(['muser'])->findOrEmpty($id);
-		$workerlist = WorkerModel::order(['id'=>'desc'])->select();
-		return view('agent/agentform',[
-			'workerlist'	=> $workerlist,
-			'agent'			=> $agent
-		]);
-	}
-	
-	public function editAgent()
-	{
-		$id = input('id/d');
-		$vdata = array(
-			'id'			=> $id,
-			'loginname'		=> input('loginname/s', ""),
-			'idnumber'		=> input('idnumber/s', "")
-		);
-		try {
-			validate(AgentValidate::class)->check($vdata);
-		} catch (ValidateException $e) {
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> $e->getError()
-			)));
-		}
-		$muser = UserModel::where(['mobile'=>input('musermobile/s', '')])->findOrEmpty();
-		if ($muser->isEmpty()){
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> "关联的用户不存在。"
-			)));
-		}
-		$data = [
-			'userid'		=> $muser->id,
-			'workerid'		=> input('workerid/d', 0),
-			'loginname'  	=> input('loginname/s', ""),
-			'idnumber'  	=> input('idnumber/s', ""),
-			'title'			=> input('title/s', ""),
-			'tilpic'		=> input('tilpic/s', ""),
-			'picall'		=> input('picall/a', array()),
-			'realname'  	=> input('realname/s', ""),
-			'mobile'    	=> input('mobile/s', ""),
-			'telephone'		=> input('telephone/s', ""),
-			'latitude'		=> input('latitude/f', 0.00),
-			'longitude'		=> input('longitude/f', 0.00),
-			'province'		=> input('province/s', ""),
-			'city'			=> input('city/s', ""),
-			'district'		=> input('district/s', ""),
-			'address'		=> input('address/s', ""),
-			'details'		=> input('details/s', ""),
-			'priority'		=> input('priority/d', 0),
-			'remark'		=> input('remark/s', ""),
-			'status'		=> input('status/d', 0)
-		];
-		$password = input('password/s', "");
-		if (empty($id)){
-			$data['password'] = empty($password) ? md5("123456789") : md5($password);
-			$data['createtime'] = time();
-			$agent = AgentModel::create($data);
-		}else{
-			if (!empty($password)){
-				$data['password'] = md5($password);
-			}
-			$agent = AgentModel::find($id);
-			$agent->save($data);
-		}
-		BrokerModel::update([
-			'workerid' => input('workerid/d', 0)
-		],['agentid'=>$agent->id]);
-		exit(json_encode(array(
-			'code' 	=> 0
-		)));
-	}
-	
-	public function fieldAgent()
-	{
-		$id = input('id/d',0); 
-		$info = AgentModel::findOrEmpty($id);
-		if ($info->isEmpty()){
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> "信息不存在"
-			)));
-		}else{
-			$info->save([
-				input('field/s')  => input('value/s', "")
-			]);
-		}
-		exit(json_encode(array(
-			'code' 	=> 0
-		)));
-	}
-	
-	public function delAgent()
-	{
-		$access_admin = session('access_admin');
-		$password = input('password');
-		if ( $access_admin['password'] !== md5($password) ){
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> "操作密码验证失败"
-			)));
-		}
-		$idarr = input('idarr/a');
-        $result = Db::name('agent')->whereIn('id',$idarr)->update(['deletetime'=>time()]);
-		if ($result){
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'	=> ""
-			)));
-		}
-		exit(json_encode(array(
-			'code' 	=> 1,
-			'msg'	=> "删除失败,请稍后重试"
-		)));
-	}
-	
-	public function listAgent()
-	{
-		$limit = input('limit');
-		$page = input('page');
-		$map = array();
-		$keywords = input('keywords/s');
-		if (!empty($keywords)){
-			$map[] =['idnumber', 'like', '%'.$keywords.'%'];
-		}
-		$workerid = input('workerid/d');
-		if (!empty($workerid)){
-			$map[] = ['workerid', '=', $workerid];
-		}
-		$status = input('status/d');
-		if (!empty($status)){
-			$map[] = ['status', '=', $status];
-		}
-		$list = AgentModel::with(['worker','muser'])->where($map)->order(['priority'=>'DESC','id'=>'DESC'])->limit($limit)->page($page)->append(['status_text'])->select();
-		$count = AgentModel::where($map)->count();
-		if ($count==0){
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> "未查询到数据"
-			)));
-		}
-		exit(json_encode(array(
-			'code' 	=> 0,
-			'msg'	=> "",
-			'count' => $count,
-			'data'  => $list
-		)));
-	}
-	
-	
-	
-	
-	// 申请注册经纪人
-	public function fagentList()
-	{
-		return view('agent/fagentlist');
-	}
-	
-	public function fagentForm()
-	{
-		$id = input('id/d, 0');
-		$fagent = AgentFormModel::findOrEmpty($id);
-		return view('agent/fagentform',[
-			'fagent'	=> $fagent
-		]);
-	}
-	
-	public function editFagent()
-	{
-		$id = input('id/d');
-		$fagent = AgentFormModel::findOrEmpty($id);
-		$fagent->save([
-			'realname'  	=> input('realname/s', ""),
-			'mobile'    	=> input('mobile/s', ""),
-			'address'		=> input('address/s', ""),
-			'idcard'		=> input('idcard/s', ""),
-			'recommender'	=> input('recommender/s', ""),
-			'status'		=> input('status/d', 1),
-			'remark'		=> input('remark/s', ""),
-			'createtime'	=> input('createtime/s', ""),
-		]);
-		exit(json_encode(array(
-			'code' 	=> 0
-		)));
-	}
-	
-	public function fieldFagent()
-	{
-		$id = input('id/d',0); 
-		$info = AgentFormModel::findOrEmpty($id);
-		if ($info->isEmpty()){
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> "信息不存在"
-			)));
-		}else{
-			$info->save([
-				input('field/s')  => input('value')
-			]);
-		}
-		exit(json_encode(array(
-			'code' 	=> 0
-		)));
-	}
-	
-	public function delFagent()
-	{
-		$idarr = input('idarr/a');
-		$fagent = AgentFormModel::whereIn('id',$idarr)->select();
-		$result = $fagent->delete();
-		if ($result){
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'	=> ""
-			)));
-		}
-		exit(json_encode(array(
-			'code' 	=> 1,
-			'msg'	=> "删除失败,请稍后重试"
-		)));
-	}
-	
-	public function listFagent()
-	{
-		$limit = input('limit');
-		$page = input('page');
-		$map = array();
-		$keywords = input('keywords/s');
-		if (!empty($keywords)){
-			$map[] =['realname|mobile', 'like', '%'.$keywords.'%'];
-		}
-		$status = input('status/d');
-		if (!empty($status)){
-			$map[] = ['status', '=', $status];
-		}
-		$list = AgentFormModel::where($map)->order('id','DESC')->limit($limit)->page($page)->append(['status_text'])->select();
-		$count = AgentFormModel::where($map)->count();
-		if ($count==0){
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> "未查询到数据"
-			)));
-		}
-		exit(json_encode(array(
-			'code' 	=> 0,
-			'msg'	=> "",
-			'count' => $count,
-			'data'  => $list
-		)));
-	}
-	
-	
-	
+
+    public function agentList()
+    {
+        $workerlist = WorkerModel::order(['id' => 'desc'])->select();
+        return view('agent/agentlist', [
+            'workerlist' => $workerlist,
+        ]);
+    }
+
+    public function agentForm()
+    {
+        $id         = input('id/d, 0');
+        $agent      = AgentModel::with(['muser'])->findOrEmpty($id);
+        $workerlist = WorkerModel::order(['id' => 'desc'])->select();
+        return view('agent/agentform', [
+            'workerlist' => $workerlist,
+            'agent'      => $agent,
+        ]);
+    }
+
+    public function editAgent()
+    {
+        $id    = input('id/d');
+        $vdata = [
+            'id'        => $id,
+            'loginname' => input('loginname/s', ""),
+            'idnumber'  => input('idnumber/s', ""),
+        ];
+        try {
+            validate(AgentValidate::class)->check($vdata);
+        } catch (ValidateException $e) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => $e->getError(),
+            ]));
+        }
+        $muser = UserModel::where(['mobile' => input('musermobile/s', '')])->findOrEmpty();
+        if ($muser->isEmpty()) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "关联的用户不存在。",
+            ]));
+        }
+        $data     = [
+            'userid'    => $muser->id,
+            'workerid'  => input('workerid/d', 0),
+            'loginname' => input('loginname/s', ""),
+            'idnumber'  => input('idnumber/s', ""),
+            'title'     => input('title/s', ""),
+            'tilpic'    => input('tilpic/s', ""),
+            'picall'    => input('picall/a', []),
+            'realname'  => input('realname/s', ""),
+            'mobile'    => input('mobile/s', ""),
+            'telephone' => input('telephone/s', ""),
+            'latitude'  => input('latitude/f', 0.00),
+            'longitude' => input('longitude/f', 0.00),
+            'province'  => input('province/s', ""),
+            'city'      => input('city/s', ""),
+            'district'  => input('district/s', ""),
+            'address'   => input('address/s', ""),
+            'details'   => input('details/s', ""),
+            'priority'  => input('priority/d', 0),
+            'remark'    => input('remark/s', ""),
+            'status'    => input('status/d', 1),
+            'is_settle' => input('is_settle/d', 1),
+        ];
+        $password = input('password/s', "");
+        if (empty($id)) {
+            $data['password']   = empty($password) ? md5("123456789") : md5($password);
+            $data['createtime'] = time();
+            $agent              = AgentModel::create($data);
+        } else {
+            if (!empty($password)) {
+                $data['password'] = md5($password);
+            }
+            $agent = AgentModel::find($id);
+            $agent->save($data);
+        }
+        BrokerModel::update([
+            'workerid' => input('workerid/d', 0),
+        ], ['agentid' => $agent->id]);
+        exit(json_encode([
+            'code' => 0,
+        ]));
+    }
+
+    public function fieldAgent()
+    {
+        $id   = input('id/d', 0);
+        $info = AgentModel::findOrEmpty($id);
+        if ($info->isEmpty()) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "信息不存在",
+            ]));
+        } else {
+            $info->save([
+                input('field/s') => input('value/s', ""),
+            ]);
+        }
+        exit(json_encode([
+            'code' => 0,
+        ]));
+    }
+
+    public function delAgent()
+    {
+        $access_admin = session('access_admin');
+        $password     = input('password');
+        if ($access_admin['password'] !== md5($password)) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "操作密码验证失败",
+            ]));
+        }
+        $idarr  = input('idarr/a');
+        $result = Db::name('agent')->whereIn('id', $idarr)->update(['deletetime' => time()]);
+        if ($result) {
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+            ]));
+        }
+        exit(json_encode([
+            'code' => 1,
+            'msg'  => "删除失败,请稍后重试",
+        ]));
+    }
+
+    public function listAgent()
+    {
+        $limit    = input('limit');
+        $page     = input('page');
+        $map      = [];
+        $keywords = input('keywords/s');
+        if (!empty($keywords)) {
+            $map[] = ['idnumber', 'like', '%' . $keywords . '%'];
+        }
+        $workerid = input('workerid/d');
+        if (!empty($workerid)) {
+            $map[] = ['workerid', '=', $workerid];
+        }
+        $status = input('status/d');
+        if (!empty($status)) {
+            $map[] = ['status', '=', $status];
+        }
+        $list  = AgentModel::with(['worker', 'muser'])->where($map)->order(['priority' => 'DESC', 'id' => 'DESC'])->limit($limit)->page($page)->append(['status_text'])->select();
+        $count = AgentModel::where($map)->count();
+        if ($count == 0) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "未查询到数据",
+            ]));
+        }
+        exit(json_encode([
+            'code'  => 0,
+            'msg'   => "",
+            'count' => $count,
+            'data'  => $list,
+        ]));
+    }
+
+
+    // 申请注册经纪人
+    public function fagentList()
+    {
+        return view('agent/fagentlist');
+    }
+
+    public function fagentForm()
+    {
+        $id     = input('id/d, 0');
+        $fagent = AgentFormModel::findOrEmpty($id);
+        return view('agent/fagentform', [
+            'fagent' => $fagent,
+        ]);
+    }
+
+    public function editFagent()
+    {
+        $id     = input('id/d');
+        $fagent = AgentFormModel::findOrEmpty($id);
+        $fagent->save([
+            'realname'    => input('realname/s', ""),
+            'mobile'      => input('mobile/s', ""),
+            'address'     => input('address/s', ""),
+            'idcard'      => input('idcard/s', ""),
+            'recommender' => input('recommender/s', ""),
+            'status'      => input('status/d', 1),
+            'remark'      => input('remark/s', ""),
+            'createtime'  => input('createtime/s', ""),
+        ]);
+        exit(json_encode([
+            'code' => 0,
+        ]));
+    }
+
+    public function fieldFagent()
+    {
+        $id   = input('id/d', 0);
+        $info = AgentFormModel::findOrEmpty($id);
+        if ($info->isEmpty()) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "信息不存在",
+            ]));
+        } else {
+            $info->save([
+                input('field/s') => input('value'),
+            ]);
+        }
+        exit(json_encode([
+            'code' => 0,
+        ]));
+    }
+
+    public function delFagent()
+    {
+        $idarr  = input('idarr/a');
+        $fagent = AgentFormModel::whereIn('id', $idarr)->select();
+        $result = $fagent->delete();
+        if ($result) {
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+            ]));
+        }
+        exit(json_encode([
+            'code' => 1,
+            'msg'  => "删除失败,请稍后重试",
+        ]));
+    }
+
+    public function listFagent()
+    {
+        $limit    = input('limit');
+        $page     = input('page');
+        $map      = [];
+        $keywords = input('keywords/s');
+        if (!empty($keywords)) {
+            $map[] = ['realname|mobile', 'like', '%' . $keywords . '%'];
+        }
+        $status = input('status/d');
+        if (!empty($status)) {
+            $map[] = ['status', '=', $status];
+        }
+        $list  = AgentFormModel::where($map)->order('id', 'DESC')->limit($limit)->page($page)->append(['status_text'])->select();
+        $count = AgentFormModel::where($map)->count();
+        if ($count == 0) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "未查询到数据",
+            ]));
+        }
+        exit(json_encode([
+            'code'  => 0,
+            'msg'   => "",
+            'count' => $count,
+            'data'  => $list,
+        ]));
+    }
+
 
 }

+ 88 - 0
app/admin/controller/Broker.php

@@ -10,6 +10,7 @@ use app\common\model\Agent as AgentModel;
 use app\common\model\Broker as BrokerModel;
 use app\common\model\Resident as ResidentModel;
 use app\common\model\BrokerForm as BrokerFormModel;
+use app\common\model\BrokerIncome as BrokerIncomeModel;
 
 use app\common\validate\Broker as BrokerValidate;
 use think\exception\ValidateException;
@@ -338,4 +339,91 @@ class Broker extends BaseController
         Config::setConfigValue('default_broker', $brokerid);
         exit(json_encode(['code' => 0]));
     }
+
+    public function cashList()
+    {
+        return view('broker/cashlist');
+    }
+
+    public function listCash()
+    {
+        $limit  = input('limit/d', 20);
+        $page   = input('page/d', 1);
+        $map    = [
+            ['type', '=', 2],
+        ];
+        $status = input('status/d');
+        if (!empty($status)) {
+            $map[] = ['status', '=', $status];
+        }
+        $list = BrokerIncomeModel::with(['broker'])->where($map)->order('status', 'ASC')->limit($limit)->page($page)->append(['status_text'])->select();
+        foreach ($list as $v) {
+            $v['value'] = abs($v['value']);
+        }
+        $count = BrokerIncomeModel::where($map)->count();
+        if ($count == 0) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "未查询到数据",
+            ]));
+        }
+        exit(json_encode([
+            'code'  => 0,
+            'msg'   => "",
+            'count' => $count,
+            'data'  => $list,
+        ]));
+    }
+
+    public function examineCash()
+    {
+        $id     = input('id/d', 0);
+        $income = BrokerIncomeModel::findOrEmpty($id);
+        if ($income->isEmpty()) {
+            exit('未查询到数据');
+        }
+        if ($income->status != 1) {
+            exit('该记录无需审核');
+        }
+
+        return view('broker/examinecash', [
+            'id' => $id,
+        ]);
+    }
+
+    public function cashExamine()
+    {
+        $id     = input('id/d', 0);
+        $income = BrokerIncomeModel::findOrEmpty($id);
+        if ($income->isEmpty()) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "未查询到数据",
+            ]));
+        }
+
+        //更改状态
+        $status         = input('status/d', 0);
+        if (empty($status)) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "请选择状态",
+            ]));
+        }
+        $remark         = input('remark', '');
+        $income->status = $status;
+        $income->remark = $remark;
+        $income->save();
+
+        //审核失败,退钱
+        if ($status == 3) {
+            $broker = BrokerModel::where('id', $income['brokerid'])->find();
+            $broker->income += abs($income['value']);
+            $broker->save();
+        }
+
+        exit(json_encode([
+            'code' => 0,
+        ]));
+    }
 }

+ 7 - 0
app/admin/view/agent/agentform.html

@@ -178,6 +178,13 @@
 								<input type="radio" name="status" value="2" title="禁用" {eq name="agent.status" value="2" }checked{/eq} />
 							</div>
 						</div>
+						<div class="layui-form-item" pane>
+							<label class="layui-form-label">收益结算</label>
+							<div class="layui-input-block">
+								<input type="radio" name="is_settle" value="1" title="是" {eq name="agent.is_settle|default=1" value="1" }checked{/eq} />
+								<input type="radio" name="is_settle" value="2" title="否" {eq name="agent.is_settle" value="2" }checked{/eq} />
+							</div>
+						</div>
 
 						<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
 							<legend>PC端管理账号密码</legend>

+ 96 - 0
app/admin/view/broker/cashlist.html

@@ -0,0 +1,96 @@
+<div class="layui-fluid">
+	<div class="layui-card">
+		<div class="layui-form layui-form-pane layui-card-header layuiadmin-card-header-auto" lay-filter="LAY-broker-cashlist-search">
+			<div class="layui-form-item">
+				<div class="layui-inline">
+					<label class="layui-form-label">状态</label>
+					<div class="layui-input-block">
+						<select name="status">
+							<option value="">全部状态</option>
+							<option value="1">待处理</option>
+							<option value="2">已成功</option>
+							<option value="3">已拒绝</option>
+						</select>
+					</div>
+				</div>
+				<div class="layui-inline">
+					<button class="layui-btn" lay-submit lay-filter="LAY-broker-cashlist-btn">
+						<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
+					</button>
+				</div>
+			</div>
+		</div>
+
+		<div class="layui-card-body">
+
+			<table id="LAY-broker-cashlist-table" lay-filter="LAY-broker-cashlist-table"></table>
+			<script type="text/html" id="brokerTpl">
+				{{d.broker.title}} - {{d.broker.mobile}}
+			</script>
+			<script type="text/html" id="setTpl">
+				{{#  if(d.status == 1){ }}
+					<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="examine"><i class="layui-icon layui-icon-edit"></i>审核</a>
+				{{#  } }}
+			</script>
+		</div>
+	</div>
+</div>
+
+<script>
+	layui.config({
+		base: '/static/echoui/' //静态资源所在路径
+	}).extend({
+		index: 'lib/index' //主入口模块
+	}).use(['index', 'form', 'set', 'table'], function() {
+		var $ = layui.$,
+			setter = layui.setter,
+			admin = layui.admin,
+			form = layui.form,
+			table = layui.table;
+		form.render();
+
+		table.render({
+			elem: '#LAY-broker-cashlist-table',
+			url: setter.baseAdminUrl + 'broker/listCash',
+			cols: [
+				[
+					{ field: 'id', width: 80, title: '表ID', sort: true },
+					{ field: 'broker', title: '经济人', templet: '#brokerTpl', minWidth: 200, align: 'left' },
+					{ field: 'title', title: '标题', width: 150, align: 'center' },
+					{ field: 'value', title: '金额', width: 100, align: 'center' },
+					{ field: 'status_text', title: '状态', width: 100, align: 'center' },
+					{ field: 'remark', title: '备注', align: 'center' },
+					{ field: 'createtime', title: '创建时间', width: 170 },
+					{ title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#setTpl' }
+				]
+			],
+			page: true,
+			limit: 50,
+			cellMinWidth: 150,
+			text: '对不起,加载出现异常!'
+		});
+
+		form.on('submit(LAY-broker-cashlist-btn)', function(data) {
+			table.reload('LAY-broker-cashlist-table', {
+				where: data.field,
+				page: {
+					curr: 1
+				}
+			});
+		});
+
+		table.on('tool(LAY-broker-cashlist-table)', function(obj) {
+			var data = obj.data;
+			if (obj.event === 'examine') {
+				var index = layer.open({
+					type: 2,
+					title: '审核',
+					content: 'examineCash.html?id=' + data.id,
+					maxmin: true,
+					area: ['750px', '380px']
+				});
+			}
+		});
+
+	});
+</script>

+ 63 - 0
app/admin/view/broker/examinecash.html

@@ -0,0 +1,63 @@
+<div class="layui-fluid">
+	<div class="layui-row layui-col-space15">
+		<div class="layui-col-md12">
+			<div class="layui-card">
+				<div class="layui-card-header">提现审核</div>
+				<div class="layui-card-body" pad15>
+
+					<div class="layui-form layui-form-pane" lay-filter="LAY-broker-cash-examine">
+						<input type="hidden" name="id" value="{$id}">
+						<div class="layui-form-item" pane>
+							<label class="layui-form-label">状态</label>
+							<div class="layui-input-block">
+								<input type="radio" name="status" value="2" title="通过">
+								<input type="radio" name="status" value="3" title="拒绝">
+							</div>
+						</div>
+						<div class="layui-form-item">
+							<label class="layui-form-label">备注</label>
+							<div class="layui-input-block">
+								<textarea name="remark" placeholder="请输入..." class="layui-textarea"></textarea>
+							</div>
+						</div>
+						<div class="layui-form-item">
+							<div class="layui-input-block">
+								<input type="button" lay-submit lay-filter="LAY-broker-cash-examine-submit" value="确认提交" class="layui-btn">
+							</div>
+						</div>
+					</div>
+
+				</div>
+			</div>
+		</div>
+	</div>
+</div>
+
+<script>
+	layui.config({
+		base: '/static/echoui/' //静态资源所在路径
+	}).extend({
+		index: 'lib/index' //主入口模块
+	}).use(['index', 'form', 'set', 'upload'], function() {
+		var $ = layui.$,
+			setter = layui.setter,
+			admin = layui.admin,
+			form = layui.form;
+		form.render();
+
+		form.on('submit(LAY-broker-cash-examine-submit)', function(obj) {
+			var index = parent.layer.getFrameIndex(window.name);
+			admin.req({
+				url: setter.baseAdminUrl + 'broker/cashExamine',
+				data: obj.field,
+				done: function(res) {
+					layer.msg("提交成功", {
+						icon: 1
+					});
+					parent.layui.table.reload('LAY-broker-cashlist-table'); //重载表格
+					parent.layer.close(index);
+				}
+			});
+		});
+	});
+</script>

+ 4 - 1
app/agent/controller/Broker.php

@@ -16,7 +16,10 @@ class Broker extends BaseController
 
     public function brokerList()
     {
-        return view('broker/brokerlist');
+        $agent  = $this->access_agent;
+        return view('broker/brokerlist',[
+            'agent'  => $agent,
+        ]);
     }
 
     public function brokerForm()

+ 2 - 0
app/agent/view/broker/brokerlist.html

@@ -46,7 +46,9 @@
 			</script>
 			<script type="text/html" id="setTpl">
 				<a class="layui-btn layui-btn-xs" lay-event="income"><i class="layui-icon layui-icon-table"></i>收益明细</a>
+				{eq name="agent.is_settle" value="1"}
 				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="settle"><i class="layui-icon layui-icon-edit"></i>收益结算</a>
+				{/eq}
 				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="transfer"><i class="layui-icon layui-icon-spread-left"></i>下线转移</a>
 				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
 				<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>

+ 1 - 0
app/common/model/Agent.php

@@ -38,6 +38,7 @@ class Agent extends Model
         'wxampcode'    => 'string',
         'income'       => 'decimal',
         'income_total' => 'decimal',
+        'is_settle'    => 'tinyint',
     ];
 
     // 设置字段自动转换类型

+ 12 - 0
app/common/model/BrokerIncome.php

@@ -17,6 +17,7 @@ class BrokerIncome extends Model
         'value'        => 'decimal',
         'remark'       => 'string',
         'status'       => 'int',
+        'type'         => 'int',
         'createtime'   => 'int',
         'yeartime'     => 'int',
         'monthtime'    => 'int',
@@ -33,4 +34,15 @@ class BrokerIncome extends Model
         return $this->hasOne(Broker::class, "id", "brokerid");
     }
 
+    public function getTypeTextAttr($value, $data)
+    {
+        $type = [1 => '普通', 2 => '提现'];
+        return $type[$data['type']];
+    }
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $type = [1 => '待处理', 2 => '已成功', 3 => '已拒绝'];
+        return $type[$data['status']];
+    }
 }

+ 13 - 9
app/common/service/IncomeService.php

@@ -10,7 +10,7 @@ use app\common\model\Agent as AgentModel;
 
 class IncomeService extends BaseService
 {
-    public function add($broker_id, $value, $title, $remark = '')
+    public function add($broker_id, $value, $title, $remark = '', $type = 1)
     {
         if (empty($value)) {
             return false;
@@ -20,7 +20,7 @@ class IncomeService extends BaseService
             $broker_id = Config::getConfigValue('default_broker');
         }
 
-        $broker   = BrokerModel::where('id', $broker_id)->find();
+        $broker = BrokerModel::where('id', $broker_id)->find();
         $income = new BrokerIncomeModel();
         $income->save([
             'brokerid'     => $broker_id,
@@ -29,6 +29,8 @@ class IncomeService extends BaseService
             'title'        => $title,
             'origin_value' => $broker['income'],
             'value'        => $value,
+            'type'         => $type,
+            'status'       => $type == 2 ? 1 : 2,
             'remark'       => $remark,
             'createtime'   => time(),
             'yeartime'     => date("Y"),
@@ -36,20 +38,22 @@ class IncomeService extends BaseService
         ]);
 
         //修改收益
-        $worker         = WorkerModel::where('id', $broker['workerid'])->find();
-        $worker->income += $value;
-        $agent          = AgentModel::where('id', $broker['agentid'])->find();
-        $agent->income  += $value;
         $broker->income += $value;
 
         //修改累计收益
         if ($value > 0) {
-            $broker->income_total += $value;
+            $worker               = WorkerModel::where('id', $broker['workerid'])->find();
+            $worker->income       += $value;
             $worker->income_total += $value;
+            $worker->save();
+
+            $agent                = AgentModel::where('id', $broker['agentid'])->find();
+            $agent->income        += $value;
             $agent->income_total  += $value;
+            $agent->save();
+
+            $broker->income_total += $value;
         }
         $broker->save();
-        $worker->save();
-        $agent->save();
     }
 }

+ 45 - 11
app/mainapp/controller/Broker.php

@@ -3,6 +3,7 @@
 namespace app\mainapp\controller;
 
 use app\common\model\BrokerIncome;
+use app\common\service\IncomeService;
 use app\mainapp\BaseController;
 
 use app\common\model\Param as ParamModel;
@@ -13,15 +14,11 @@ use app\common\model\Broker as BrokerModel;
 use app\common\model\BrokerForm as BrokerFormModel;
 use app\common\model\DemandSnatch as DemandSnatchModel;
 use app\common\model\DemandReport as DemandReportModel;
+use app\common\model\Agent as AgentModel;
 
 use app\common\validate\DemandReport as DemandReportValidate;
 use think\exception\ValidateException;
 
-/*use app\common\model\ReportEntry as ReportEntryModel;
-use app\common\model\ReportFactory as ReportFactoryModel;
-use app\common\model\ReportOrder as ReportOrderModel;
-use app\common\model\ReportOrderlog as ReportOrderlogModel;*/
-
 class Broker extends BaseController
 {
 
@@ -157,10 +154,10 @@ class Broker extends BaseController
 
         //数据检验
         $data = [
-            'demandid'  => $snatch['demand_id'],
+            'demandid'   => $snatch['demand_id'],
             'snatchid'   => $snatchid,
-            'workerid'    => $broker['workerid'],
-            'agentid'   => $broker['agentid'],
+            'workerid'   => $broker['workerid'],
+            'agentid'    => $broker['agentid'],
             'brokerid'   => $broker['id'],
             'realname'   => input('realname/s', ""),
             'mobile'     => input('mobile/s', ""),
@@ -176,7 +173,7 @@ class Broker extends BaseController
             page_result(1, $e->getError());
         }
 
-        $mobile_check  = DemandReportModel::where('snatchid', $snatchid)->where('mobile', $data['mobile'])->find();
+        $mobile_check = DemandReportModel::where('snatchid', $snatchid)->where('mobile', $data['mobile'])->find();
         if (!empty($mobile_check)) {
             exit(json_encode([
                 'code' => 1,
@@ -457,7 +454,6 @@ class Broker extends BaseController
     }
 
 
-
     /**
      * 获取收益列表
      */
@@ -469,7 +465,12 @@ class Broker extends BaseController
         if ($brokerid != 0) {
             $map[] = ['brokerid', '=', $brokerid];
         }
-        $plist = BrokerIncome::where($map)->order(['id' => 'desc'])->page($ppage)->limit($psize)->select();
+        $plist = BrokerIncome::where($map)
+            ->order(['id' => 'desc'])
+            ->page($ppage)
+            ->limit($psize)
+            ->append(['status_text'])
+            ->select();
         page_result(0, "", [
             'plist'   => $plist,
             'pstatus' => $psize > count($plist) ? 'noMore' : 'more',
@@ -490,4 +491,37 @@ class Broker extends BaseController
             'month_income' => $month_income,
         ]);
     }
+
+    public function cash()
+    {
+        $brokerid = input('brokerid/d', 0);
+        $value    = input('value/d', 0);
+        $broker   = BrokerModel::findOrEmpty($brokerid);
+        if ($broker->isEmpty()) {
+            page_result(1, "用户信息不存在。");
+        }
+        $agent = AgentModel::findOrEmpty($broker['agentid']);
+        if ($agent['is_settle'] == 1) {
+            page_result(1, "请线下与门店结算。");
+        }
+        if ($value <= 0) {
+            page_result(1, "提现金额必须大于0。");
+        }
+        if ($value > $broker['income']) {
+            page_result(1, "收益不足。");
+        }
+
+        $service = new IncomeService();
+        $service->add($brokerid, -$value, '经济人发起提现', '', 2);
+
+        page_result();
+    }
+
+    public function agent()
+    {
+        $agentid = input('agentid/d', 0);
+        $agent   = AgentModel::findOrEmpty($agentid);
+
+        page_result(0, '', $agent);
+    }
 }