display(); } /** * 直连分润页面 */ public function linkIndex() { $this->display(); } /** * 新大陆分润页面 */ public function union() { $this->display(); } /** * 乐返分润页面 */ public function happy() { $this->display(); } /** * 拉卡拉分润页面 */ public function laKaLa() { $this->display(); } /** * 钱客云分润页面 */ public function moneyQuest() { $this->display(); } /** * 提现记录管理页面 */ public function cashManager() { $this->display(); } /** * 获取分润列表 */ public function profitList() { $data = I('post.'); $data['operator_type'] = 1; $data['user_type'] = 1; $data['partner_id'] = $this->partner_id; $ProfitClass = new BranchProfit(); $result = $ProfitClass->getList($data); $this->ajaxReturn($result); } /** * 获取分润统计 */ public function profitTotal() { $data = I('post.'); $data['operator_type'] = 1; $data['user_type'] = 1; $data['partner_id'] = $this->partner_id; $ProfitClass = new BranchProfit(); $result = $ProfitClass->profitTotal($data); $this->ajaxReturn($result); } /** * 获取提现记录 * @throws \think\Exception * @throws \think\db\exception\DbException * @throws \think\exception\DbException */ public function getCashOrder() { $date = I('post.selectDate'); $agent_id = I('post.agent_id'); $type = I('post.selectType'); $page = I('post.page'); $limit = I('post.limit'); if (!empty($agent_id)) { $where['c.agent_id'] = $agent_id; } $where['c.partner_id'] = $this->partner_id; if (!empty($type)) { switch ($type) { case "1": $where['c.state'] = 1; break; case "2": $where['c.state'] = 2; break; case "3": $where['c.state'] = 3; break; default: $where['c.state'] = array('in', '1,2,3'); } } if ($date) { $start = strtotime(date('Y-m-d', strtotime($date[0]))); $end = strtotime(date('Y-m-d', strtotime($date[1]))) + 86400; $where['c.add_time'] = array('between', $start . ',' . $end); } $where['c.status'] = 0; $count = M('cash_from_agent as c')->where($where)->count(); $info = M('cash_from_agent as c') ->join('ls_retail_agent as a on a.id=c.agent_id') ->where($where)->page($page, $limit) ->order('c.add_time desc') ->field('c.*,a.name') ->select(); $allMoney = M('continent_cash')->where(array('state' => 0))->sum('agent_profit'); $allMoney = $allMoney ? $allMoney : 0; $refundMoney = M('continent_cash')->where(array('state' => 0))->sum('agent_refund_profit'); $refundMoney = $refundMoney ? $refundMoney : 0; $allMoney = round($allMoney - $refundMoney, 2); $loadMoney = M('cash_from_agent')->where(array('state' => 1))->sum('withdrawal_amount'); $loadMoney = $loadMoney ? $loadMoney : 0; $settledMoney = M('cash_from_agent')->where(array('state' => 2))->sum('withdrawal_amount'); $settledMoney = $settledMoney ? $settledMoney : 0; if (!empty($info)) { foreach ($info as $key => &$val) { $val['index'] = round((($page - 1) * $limit) + $key + 1); $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); if ($val['settled_time']) { $val['settled_time'] = date('Y-m-d H:i:s', $val['settled_time']); } $val['withdrawal_amount'] = floatval($val['withdrawal_amount']); } } $res['allMoney'] = $allMoney; $res['loadMoney'] = $loadMoney; $res['settledMoney'] = $settledMoney; $res['page'] = (int)$page; $res['status'] = 1; $res['msg'] = '获取成功'; $res['data'] = $info; $res['count'] = (int)$count; $this->ajaxReturn($res); } /** * 驳回提现申请 * @throws \think\Exception * @throws \think\db\exception\DbException * @throws \think\exception\DbException */ public function toReject() { $id = I('post.id'); $reason = I('post.reason'); $order = M('cash_from_agent')->where(array('id' => $id, 'partner_id' => $this->partner_id, 'state' => 1))->find(); if (empty($order)) { $res['status'] = 0; $res['msg'] = '请勿频繁点击'; } else { $save = array( 'state' => 3, 'settled_time' => time(), 'reason' => $reason ); $update = M('cash_from_agent')->where(array('id' => $id, 'partner_id' => $this->partner_id, 'state' => 1))->save($save); if ($update) { M('retail_agent')->where(array('id' => $order['agent_id']))->setInc('balance', $order['withdrawal_amount']); $res['status'] = 1; $res['msg'] = '驳回成功'; } else { $res['status'] = 0; $res['msg'] = '驳回失败,请重试'; } } $this->ajaxReturn($res); } /** * 同意提现申请 * @throws \think\db\exception\DbException * @throws \think\exception\DbException */ public function toPass() { $id = I('post.id'); $order = M('cash_from_agent')->where(array('id' => $id, 'partner_id' => $this->partner_id, 'state' => 1))->find(); if (empty($order)) { $res['status'] = 0; $res['msg'] = '请勿频繁点击'; } else { $save = array( 'state' => 2, 'settled_time' => time() ); $update = M('cash_from_agent')->where(array('id' => $id, 'partner_id' => $this->partner_id, 'state' => 1))->save($save); if ($update) { $res['status'] = 1; $res['msg'] = '修改成功'; } else { $res['status'] = 1; $res['msg'] = '修改失败,请重试'; } } $this->ajaxReturn($res); } }