208 行
5.8 KiB
PHP
可执行文件
208 行
5.8 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Agent\Controller;
|
|
|
|
use Common\Business\BranchProfit;
|
|
use Common\Model\RetailAgentModel;
|
|
use Think\Controller;
|
|
|
|
//[1.9.5]
|
|
|
|
/**
|
|
* 代理商分润
|
|
* Class ContinentflowController
|
|
* @package Agent\Controller
|
|
*/
|
|
class ContinentflowController extends BaseController
|
|
{
|
|
/**
|
|
* 新大陆分润列表页
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->display();
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取分润列表
|
|
*/
|
|
public function profitList()
|
|
{
|
|
$data = I('post.');
|
|
$data['operator_type'] = 1;
|
|
$data['user_type'] = 2;
|
|
$data['agent_id'] = $this->agent_id;
|
|
$ProfitClass = new BranchProfit();
|
|
$result = $ProfitClass->getList($data);
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
/**
|
|
* 获取分润统计
|
|
*/
|
|
public function profitTotal()
|
|
{
|
|
$data = I('post.');
|
|
$data['operator_type'] = 1;
|
|
$data['user_type'] = 2;
|
|
$data['agent_id'] = $this->agent_id;
|
|
$ProfitClass = new BranchProfit();
|
|
$result = $ProfitClass->profitTotal($data);
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
/**
|
|
* 直连分润页面
|
|
*/
|
|
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();
|
|
}
|
|
|
|
/**
|
|
* 获取提现列表
|
|
* @throws \think\Exception
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function getCashOrder()
|
|
{
|
|
$date = I('post.selectDate');
|
|
$type = I('post.selectType');
|
|
$page = I('post.page');
|
|
$limit = I('post.limit');
|
|
$where['agent_id'] = $this->agent_id;
|
|
if (!empty($type)) {
|
|
switch ($type) {
|
|
case "1":
|
|
$where['state'] = 1;
|
|
break;
|
|
case "2":
|
|
$where['state'] = 2;
|
|
break;
|
|
case "3":
|
|
$where['state'] = 3;
|
|
break;
|
|
default:
|
|
$where['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['add_time'] = array('between', $start . ',' . $end);
|
|
}
|
|
$where['status'] = 0;
|
|
$count = M('cash_from_agent')->where($where)->count();
|
|
$info = M('cash_from_agent')->where($where)->page($page, $limit)->order('add_time desc')->select();
|
|
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']);
|
|
}
|
|
}
|
|
$where['state'] = 1;
|
|
$loadMoney = M('cash_from_agent')->where($where)->sum('withdrawal_amount');
|
|
$loadMoney = $loadMoney ? $loadMoney : 0;
|
|
$where['state'] = 2;
|
|
$settledMoney = M('cash_from_agent')->where($where)->sum('withdrawal_amount');
|
|
$settledMoney = $settledMoney ? $settledMoney : 0;
|
|
$balance = D('RetailAgent')->getFindField(array('id' => $this->agent_id), 'balance');
|
|
$res['balance'] = $balance;
|
|
$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);
|
|
}
|
|
|
|
public function toCash()
|
|
{
|
|
$money = I('post.money');
|
|
if (!is_numeric($money) || round($money, 2) != $money) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = '请填写正确的金额';
|
|
} else {
|
|
$AgentModel = new RetailAgentModel();
|
|
$balance = $AgentModel->getFindField(['id' => $this->agent_id], 'balance');
|
|
if (floatval($balance) < floatval($money)) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = '余额不足';
|
|
} else {
|
|
$add = array(
|
|
'agent_id' => $this->agent_id,
|
|
'partner_id' => $this->partner_id,
|
|
'withdrawal_amount' => $money,
|
|
'state' => 1,
|
|
'add_time' => time(),
|
|
'status' => 0
|
|
);
|
|
$id = M('cash_from_agent')->add($add);
|
|
if ($id) {
|
|
$changeMoney = round($balance - $money, 2);
|
|
$update = $AgentModel->updateOrder(['id' => $this->agent_id], ['balance' => $changeMoney]);
|
|
if ($update) {
|
|
$res['status'] = 1;
|
|
$res['msg'] = '申请成功,请等待审核打款';
|
|
$res['balance'] = $changeMoney;
|
|
} else {
|
|
$res['status'] = 0;
|
|
$res['msg'] = '申请失败,请重试';
|
|
M('cash_from_agent')->where(array('id' => $id))->delete();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->ajaxReturn($res);
|
|
}
|
|
} |